diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0.sql index f2c62d3757..0282f8a446 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - subq_14.buys AS visit_buy_conversions + subq_23.buys AS visit_buy_conversions FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , COALESCE(MAX(subq_13.buys), 0) AS buys + MAX(subq_12.visits) AS visits + , COALESCE(MAX(subq_22.buys), 0) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC(visits_source_src_28011.ds, day) AS ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC(visits_source_src_28011.ds, day) AS visit__ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS visit__ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS visit__ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS visit__ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS visit__ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC(visits_source_src_28011.ds, day) AS ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC(visits_source_src_28011.ds, day) AS visit__ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS visit__ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS visit__ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS visit__ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS visit__ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GENERATE_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC(buys_source_src_28002.ds, day) AS ds__day - , DATE_TRUNC(buys_source_src_28002.ds, isoweek) AS ds__week - , DATE_TRUNC(buys_source_src_28002.ds, month) AS ds__month - , DATE_TRUNC(buys_source_src_28002.ds, quarter) AS ds__quarter - , DATE_TRUNC(buys_source_src_28002.ds, year) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM buys_source_src_28002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28002.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC(buys_source_src_28002.ds, day) AS buy__ds__day - , DATE_TRUNC(buys_source_src_28002.ds, isoweek) AS buy__ds__week - , DATE_TRUNC(buys_source_src_28002.ds, month) AS buy__ds__month - , DATE_TRUNC(buys_source_src_28002.ds, quarter) AS buy__ds__quarter - , DATE_TRUNC(buys_source_src_28002.ds, year) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , IF(EXTRACT(dayofweek FROM buys_source_src_28002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28002.ds) - 1) AS buy__ds__extract_dow - , EXTRACT(dayofyear FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC(buys_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(buys_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(buys_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(buys_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(buys_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC(buys_source_src_28000.ds, day) AS buy__ds__day + , DATE_TRUNC(buys_source_src_28000.ds, isoweek) AS buy__ds__week + , DATE_TRUNC(buys_source_src_28000.ds, month) AS buy__ds__month + , DATE_TRUNC(buys_source_src_28000.ds, quarter) AS buy__ds__quarter + , DATE_TRUNC(buys_source_src_28000.ds, year) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28000.ds) - 1) AS buy__ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATE_SUB(CAST(subq_9.ds__day AS DATETIME), INTERVAL 7 day) + subq_15.ds__day > DATE_SUB(CAST(subq_18.ds__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0_optimized.sql index cd16ddbf70..0e871003e2 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_count_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions + COALESCE(MAX(subq_37.buys), 0) AS visit_buy_conversions FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC(ds, day) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATE_SUB(CAST(subq_24.ds__day AS DATETIME), INTERVAL 7 day) + subq_30.ds__day > DATE_SUB(CAST(subq_33.ds__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0.sql index 3a164d16c2..ce92108969 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0.sql @@ -1,352 +1,356 @@ -- Compute Metrics via Expressions SELECT - subq_14.visit__referrer_id - , CAST(subq_14.buys AS FLOAT64) / CAST(NULLIF(subq_14.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate + subq_23.visit__referrer_id + , CAST(subq_23.buys AS FLOAT64) / CAST(NULLIF(subq_23.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT - subq_1.visit__referrer_id - , subq_1.visits + subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC(visits_source_src_28011.ds, day) AS ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC(visits_source_src_28011.ds, day) AS visit__ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS visit__ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS visit__ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS visit__ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS visit__ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY visit__referrer_id - ) subq_3 + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id'] SELECT - subq_11.visit__referrer_id - , subq_11.buys + subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_10.ds__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC(visits_source_src_28011.ds, day) AS ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC(visits_source_src_28011.ds, day) AS visit__ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS visit__ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS visit__ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS visit__ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS visit__ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GENERATE_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC(buys_source_src_28002.ds, day) AS ds__day - , DATE_TRUNC(buys_source_src_28002.ds, isoweek) AS ds__week - , DATE_TRUNC(buys_source_src_28002.ds, month) AS ds__month - , DATE_TRUNC(buys_source_src_28002.ds, quarter) AS ds__quarter - , DATE_TRUNC(buys_source_src_28002.ds, year) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM buys_source_src_28002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28002.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC(buys_source_src_28002.ds, day) AS buy__ds__day - , DATE_TRUNC(buys_source_src_28002.ds, isoweek) AS buy__ds__week - , DATE_TRUNC(buys_source_src_28002.ds, month) AS buy__ds__month - , DATE_TRUNC(buys_source_src_28002.ds, quarter) AS buy__ds__quarter - , DATE_TRUNC(buys_source_src_28002.ds, year) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , IF(EXTRACT(dayofweek FROM buys_source_src_28002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28002.ds) - 1) AS buy__ds__extract_dow - , EXTRACT(dayofyear FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC(buys_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(buys_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(buys_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(buys_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(buys_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC(buys_source_src_28000.ds, day) AS buy__ds__day + , DATE_TRUNC(buys_source_src_28000.ds, isoweek) AS buy__ds__week + , DATE_TRUNC(buys_source_src_28000.ds, month) AS buy__ds__month + , DATE_TRUNC(buys_source_src_28000.ds, quarter) AS buy__ds__quarter + , DATE_TRUNC(buys_source_src_28000.ds, year) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28000.ds) - 1) AS buy__ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON - (subq_6.user = subq_9.user) AND ((subq_6.ds__day <= subq_9.ds__day)) - ) subq_10 - ) subq_11 - ) subq_12 + ( + subq_15.user = subq_18.user + ) AND ( + (subq_15.ds__day <= subq_18.ds__day) + ) + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY visit__referrer_id - ) subq_13 + ) subq_22 ON - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id GROUP BY visit__referrer_id -) subq_14 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0_optimized.sql index a19a98472b..08b69fe9f1 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'visit__referrer_id'] @@ -35,12 +35,12 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -50,8 +50,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -61,20 +61,20 @@ FROM ( , user_id AS user , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - (subq_21.ds__day <= subq_24.ds__day) + (subq_30.ds__day <= subq_33.ds__day) ) - ) subq_25 + ) subq_34 GROUP BY visit__referrer_id - ) subq_28 + ) subq_37 ON - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id GROUP BY visit__referrer_id -) subq_29 +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0.sql index 5b39c3a0b5..35167c4bac 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0.sql @@ -1,381 +1,381 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS FLOAT64) / CAST(NULLIF(subq_14.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_by_session + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS FLOAT64) / CAST(NULLIF(subq_23.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_by_session FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC(visits_source_src_28011.ds, day) AS ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC(visits_source_src_28011.ds, day) AS visit__ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS visit__ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS visit__ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS visit__ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS visit__ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__day , visit__referrer_id - ) subq_3 + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.session - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.session + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_6.session) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_15.session) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user', 'session'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.session - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.session + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC(visits_source_src_28011.ds, day) AS ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC(visits_source_src_28011.ds, day) AS visit__ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS visit__ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS visit__ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS visit__ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS visit__ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GENERATE_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC(buys_source_src_28002.ds, day) AS ds__day - , DATE_TRUNC(buys_source_src_28002.ds, isoweek) AS ds__week - , DATE_TRUNC(buys_source_src_28002.ds, month) AS ds__month - , DATE_TRUNC(buys_source_src_28002.ds, quarter) AS ds__quarter - , DATE_TRUNC(buys_source_src_28002.ds, year) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM buys_source_src_28002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28002.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC(buys_source_src_28002.ds, day) AS buy__ds__day - , DATE_TRUNC(buys_source_src_28002.ds, isoweek) AS buy__ds__week - , DATE_TRUNC(buys_source_src_28002.ds, month) AS buy__ds__month - , DATE_TRUNC(buys_source_src_28002.ds, quarter) AS buy__ds__quarter - , DATE_TRUNC(buys_source_src_28002.ds, year) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , IF(EXTRACT(dayofweek FROM buys_source_src_28002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28002.ds) - 1) AS buy__ds__extract_dow - , EXTRACT(dayofyear FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC(buys_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(buys_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(buys_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(buys_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(buys_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC(buys_source_src_28000.ds, day) AS buy__ds__day + , DATE_TRUNC(buys_source_src_28000.ds, isoweek) AS buy__ds__week + , DATE_TRUNC(buys_source_src_28000.ds, month) AS buy__ds__month + , DATE_TRUNC(buys_source_src_28000.ds, quarter) AS buy__ds__quarter + , DATE_TRUNC(buys_source_src_28000.ds, year) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28000.ds) - 1) AS buy__ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( - subq_6.session = subq_9.session_id + subq_15.session = subq_18.session_id ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATE_SUB(CAST(subq_9.ds__day AS DATETIME), INTERVAL 7 day) + subq_15.ds__day > DATE_SUB(CAST(subq_18.ds__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY metric_time__day , visit__referrer_id - ) subq_13 + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY metric_time__day , visit__referrer_id -) subq_14 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0_optimized.sql index d6c6f149cc..99468f5ed2 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_constant_properties__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC(ds, day) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,14 +41,14 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_21.session) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_30.session) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -60,8 +60,8 @@ FROM ( , session_id AS session , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -72,32 +72,32 @@ FROM ( , session_id , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - subq_21.session = subq_24.session_id + subq_30.session = subq_33.session_id ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATE_SUB(CAST(subq_24.ds__day AS DATETIME), INTERVAL 7 day) + subq_30.ds__day > DATE_SUB(CAST(subq_33.ds__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY metric_time__day , visit__referrer_id -) subq_29 +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0.sql index 9c335f3958..b9c4a3c9c5 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_14.buys AS FLOAT64) / CAST(NULLIF(subq_14.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days + CAST(subq_23.buys AS FLOAT64) / CAST(NULLIF(subq_23.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC(visits_source_src_28011.ds, day) AS ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC(visits_source_src_28011.ds, day) AS visit__ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS visit__ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS visit__ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS visit__ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS visit__ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC(visits_source_src_28011.ds, day) AS ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC(visits_source_src_28011.ds, day) AS visit__ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS visit__ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS visit__ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS visit__ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS visit__ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GENERATE_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC(buys_source_src_28002.ds, day) AS ds__day - , DATE_TRUNC(buys_source_src_28002.ds, isoweek) AS ds__week - , DATE_TRUNC(buys_source_src_28002.ds, month) AS ds__month - , DATE_TRUNC(buys_source_src_28002.ds, quarter) AS ds__quarter - , DATE_TRUNC(buys_source_src_28002.ds, year) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM buys_source_src_28002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28002.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC(buys_source_src_28002.ds, day) AS buy__ds__day - , DATE_TRUNC(buys_source_src_28002.ds, isoweek) AS buy__ds__week - , DATE_TRUNC(buys_source_src_28002.ds, month) AS buy__ds__month - , DATE_TRUNC(buys_source_src_28002.ds, quarter) AS buy__ds__quarter - , DATE_TRUNC(buys_source_src_28002.ds, year) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , IF(EXTRACT(dayofweek FROM buys_source_src_28002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28002.ds) - 1) AS buy__ds__extract_dow - , EXTRACT(dayofyear FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC(buys_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(buys_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(buys_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(buys_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(buys_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC(buys_source_src_28000.ds, day) AS buy__ds__day + , DATE_TRUNC(buys_source_src_28000.ds, isoweek) AS buy__ds__week + , DATE_TRUNC(buys_source_src_28000.ds, month) AS buy__ds__month + , DATE_TRUNC(buys_source_src_28000.ds, quarter) AS buy__ds__quarter + , DATE_TRUNC(buys_source_src_28000.ds, year) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28000.ds) - 1) AS buy__ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATE_SUB(CAST(subq_9.ds__day AS DATETIME), INTERVAL 7 day) + subq_15.ds__day > DATE_SUB(CAST(subq_18.ds__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0_optimized.sql index e527a79a88..33962562bf 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_28.buys) AS FLOAT64) / CAST(NULLIF(MAX(subq_18.visits), 0) AS FLOAT64) AS visit_buy_conversion_rate_7days + CAST(MAX(subq_37.buys) AS FLOAT64) / CAST(NULLIF(MAX(subq_27.visits), 0) AS FLOAT64) AS visit_buy_conversion_rate_7days FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC(ds, day) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATE_SUB(CAST(subq_24.ds__day AS DATETIME), INTERVAL 7 day) + subq_30.ds__day > DATE_SUB(CAST(subq_33.ds__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0.sql index 50bc6e6fef..a560ec423d 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0.sql @@ -1,376 +1,376 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS FLOAT64) / CAST(NULLIF(subq_14.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS FLOAT64) / CAST(NULLIF(subq_23.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC(visits_source_src_28011.ds, day) AS ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC(visits_source_src_28011.ds, day) AS visit__ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS visit__ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS visit__ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS visit__ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS visit__ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__day , visit__referrer_id - ) subq_3 + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC(visits_source_src_28011.ds, day) AS ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC(visits_source_src_28011.ds, day) AS visit__ds__day - , DATE_TRUNC(visits_source_src_28011.ds, isoweek) AS visit__ds__week - , DATE_TRUNC(visits_source_src_28011.ds, month) AS visit__ds__month - , DATE_TRUNC(visits_source_src_28011.ds, quarter) AS visit__ds__quarter - , DATE_TRUNC(visits_source_src_28011.ds, year) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , IF(EXTRACT(dayofweek FROM visits_source_src_28011.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28011.ds) - 1) AS visit__ds__extract_dow - , EXTRACT(dayofyear FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATE_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATE_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATE_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATE_TRUNC(visits_source_src_28000.ds, year) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , IF(EXTRACT(dayofweek FROM visits_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM visits_source_src_28000.ds) - 1) AS visit__ds__extract_dow + , EXTRACT(dayofyear FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GENERATE_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC(buys_source_src_28002.ds, day) AS ds__day - , DATE_TRUNC(buys_source_src_28002.ds, isoweek) AS ds__week - , DATE_TRUNC(buys_source_src_28002.ds, month) AS ds__month - , DATE_TRUNC(buys_source_src_28002.ds, quarter) AS ds__quarter - , DATE_TRUNC(buys_source_src_28002.ds, year) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM buys_source_src_28002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28002.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC(buys_source_src_28002.ds, day) AS buy__ds__day - , DATE_TRUNC(buys_source_src_28002.ds, isoweek) AS buy__ds__week - , DATE_TRUNC(buys_source_src_28002.ds, month) AS buy__ds__month - , DATE_TRUNC(buys_source_src_28002.ds, quarter) AS buy__ds__quarter - , DATE_TRUNC(buys_source_src_28002.ds, year) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , IF(EXTRACT(dayofweek FROM buys_source_src_28002.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28002.ds) - 1) AS buy__ds__extract_dow - , EXTRACT(dayofyear FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC(buys_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(buys_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(buys_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(buys_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(buys_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC(buys_source_src_28000.ds, day) AS buy__ds__day + , DATE_TRUNC(buys_source_src_28000.ds, isoweek) AS buy__ds__week + , DATE_TRUNC(buys_source_src_28000.ds, month) AS buy__ds__month + , DATE_TRUNC(buys_source_src_28000.ds, quarter) AS buy__ds__quarter + , DATE_TRUNC(buys_source_src_28000.ds, year) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , IF(EXTRACT(dayofweek FROM buys_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM buys_source_src_28000.ds) - 1) AS buy__ds__extract_dow + , EXTRACT(dayofyear FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATE_SUB(CAST(subq_9.ds__day AS DATETIME), INTERVAL 7 day) + subq_15.ds__day > DATE_SUB(CAST(subq_18.ds__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY metric_time__day , visit__referrer_id - ) subq_13 + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY metric_time__day , visit__referrer_id -) subq_14 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0_optimized.sql index 2a140f4690..280fc0dc92 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_rate_with_window__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC(ds, day) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,13 +41,13 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -58,8 +58,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -69,30 +69,30 @@ FROM ( , user_id AS user , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATE_SUB(CAST(subq_24.ds__day AS DATETIME), INTERVAL 7 day) + subq_30.ds__day > DATE_SUB(CAST(subq_33.ds__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY metric_time__day , visit__referrer_id -) subq_29 +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0.sql index c61789e34d..ac7f0473ec 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - subq_14.buys AS visit_buy_conversions + subq_23.buys AS visit_buy_conversions FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , COALESCE(MAX(subq_13.buys), 0) AS buys + MAX(subq_12.visits) AS visits + , COALESCE(MAX(subq_22.buys), 0) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + subq_15.ds__day > DATEADD(day, -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0_optimized.sql index fda19c9ba7..b7fdf5e3f1 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_count_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions + COALESCE(MAX(subq_37.buys), 0) AS visit_buy_conversions FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC('day', ds) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + subq_30.ds__day > DATEADD(day, -7, subq_33.ds__day) ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0.sql index c7538526cb..6cc0d20703 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0.sql @@ -1,352 +1,356 @@ -- Compute Metrics via Expressions SELECT - subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate + subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT - subq_1.visit__referrer_id - , subq_1.visits + subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.visit__referrer_id - ) subq_3 + subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id'] SELECT - subq_11.visit__referrer_id - , subq_11.buys + subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_10.ds__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON - (subq_6.user = subq_9.user) AND ((subq_6.ds__day <= subq_9.ds__day)) - ) subq_10 - ) subq_11 - ) subq_12 + ( + subq_15.user = subq_18.user + ) AND ( + (subq_15.ds__day <= subq_18.ds__day) + ) + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.visit__referrer_id - ) subq_13 + subq_21.visit__referrer_id + ) subq_22 ON - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id GROUP BY - COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0_optimized.sql index 931728e510..ff5e5accc4 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'visit__referrer_id'] @@ -35,12 +35,12 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -50,8 +50,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -61,20 +61,20 @@ FROM ( , user_id AS user , 1 AS buys , UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - (subq_21.ds__day <= subq_24.ds__day) + (subq_30.ds__day <= subq_33.ds__day) ) - ) subq_25 + ) subq_34 GROUP BY visit__referrer_id - ) subq_28 + ) subq_37 ON - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id GROUP BY - COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0.sql index ebca9b9a90..1532003d05 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0.sql @@ -1,381 +1,381 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - , subq_2.visit__referrer_id - ) subq_3 + subq_11.metric_time__day + , subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.session - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.session + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_6.session) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_15.session) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user', 'session'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.session - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.session + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( - subq_6.session = subq_9.session_id + subq_15.session = subq_18.session_id ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + subq_15.ds__day > DATEADD(day, -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.metric_time__day - , subq_12.visit__referrer_id - ) subq_13 + subq_21.metric_time__day + , subq_21.visit__referrer_id + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0_optimized.sql index 2a50be7d76..717d7995dc 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_constant_properties__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,14 +41,14 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_21.session) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_30.session) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -60,8 +60,8 @@ FROM ( , session_id AS session , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -72,32 +72,32 @@ FROM ( , session_id , 1 AS buys , UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - subq_21.session = subq_24.session_id + subq_30.session = subq_33.session_id ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + subq_30.ds__day > DATEADD(day, -7, subq_33.ds__day) ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0.sql index 157d1418c3..ab7a3bcc96 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + subq_15.ds__day > DATEADD(day, -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0_optimized.sql index 9ada7cb337..a9778bf3d2 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_28.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_18.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(MAX(subq_37.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_27.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC('day', ds) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + subq_30.ds__day > DATEADD(day, -7, subq_33.ds__day) ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0.sql index f666d7f15d..0a64ca57d0 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0.sql @@ -1,376 +1,376 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - , subq_2.visit__referrer_id - ) subq_3 + subq_11.metric_time__day + , subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + subq_15.ds__day > DATEADD(day, -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.metric_time__day - , subq_12.visit__referrer_id - ) subq_13 + subq_21.metric_time__day + , subq_21.visit__referrer_id + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0_optimized.sql index a6f6baac27..b468242a66 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_rate_with_window__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,13 +41,13 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -58,8 +58,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -69,30 +69,30 @@ FROM ( , user_id AS user , 1 AS buys , UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + subq_30.ds__day > DATEADD(day, -7, subq_33.ds__day) ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0.sql index 540e2a2ff7..0c97a6245d 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - subq_14.buys AS visit_buy_conversions + subq_23.buys AS visit_buy_conversions FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , COALESCE(MAX(subq_13.buys), 0) AS buys + MAX(subq_12.visits) AS visits + , COALESCE(MAX(subq_22.buys), 0) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > subq_9.ds__day - INTERVAL 7 day + subq_15.ds__day > subq_18.ds__day - INTERVAL 7 day ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0_optimized.sql index 9d6d3dda85..b2a9a57124 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_count_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions + COALESCE(MAX(subq_37.buys), 0) AS visit_buy_conversions FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC('day', ds) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > subq_24.ds__day - INTERVAL 7 day + subq_30.ds__day > subq_33.ds__day - INTERVAL 7 day ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0.sql index 585c478f6e..e005899f09 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0.sql @@ -1,352 +1,356 @@ -- Compute Metrics via Expressions SELECT - subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate + subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT - subq_1.visit__referrer_id - , subq_1.visits + subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.visit__referrer_id - ) subq_3 + subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id'] SELECT - subq_11.visit__referrer_id - , subq_11.buys + subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_10.ds__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON - (subq_6.user = subq_9.user) AND ((subq_6.ds__day <= subq_9.ds__day)) - ) subq_10 - ) subq_11 - ) subq_12 + ( + subq_15.user = subq_18.user + ) AND ( + (subq_15.ds__day <= subq_18.ds__day) + ) + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.visit__referrer_id - ) subq_13 + subq_21.visit__referrer_id + ) subq_22 ON - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id GROUP BY - COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0_optimized.sql index ec4ac685fa..6b7ddcef57 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'visit__referrer_id'] @@ -35,12 +35,12 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -50,8 +50,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -61,20 +61,20 @@ FROM ( , user_id AS user , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - (subq_21.ds__day <= subq_24.ds__day) + (subq_30.ds__day <= subq_33.ds__day) ) - ) subq_25 + ) subq_34 GROUP BY visit__referrer_id - ) subq_28 + ) subq_37 ON - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id GROUP BY - COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0.sql index 348f11a2fd..fe163ea046 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0.sql @@ -1,381 +1,381 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - , subq_2.visit__referrer_id - ) subq_3 + subq_11.metric_time__day + , subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.session - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.session + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_6.session) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_15.session) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user', 'session'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.session - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.session + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( - subq_6.session = subq_9.session_id + subq_15.session = subq_18.session_id ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > subq_9.ds__day - INTERVAL 7 day + subq_15.ds__day > subq_18.ds__day - INTERVAL 7 day ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.metric_time__day - , subq_12.visit__referrer_id - ) subq_13 + subq_21.metric_time__day + , subq_21.visit__referrer_id + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0_optimized.sql index 1c8008764c..ef31de6df1 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_constant_properties__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,14 +41,14 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_21.session) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_30.session) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -60,8 +60,8 @@ FROM ( , session_id AS session , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -72,32 +72,32 @@ FROM ( , session_id , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - subq_21.session = subq_24.session_id + subq_30.session = subq_33.session_id ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > subq_24.ds__day - INTERVAL 7 day + subq_30.ds__day > subq_33.ds__day - INTERVAL 7 day ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0.sql index c6bd93429f..1d2d9fd5c3 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > subq_9.ds__day - INTERVAL 7 day + subq_15.ds__day > subq_18.ds__day - INTERVAL 7 day ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0_optimized.sql index e93cebcc83..21705a38bb 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_28.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_18.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(MAX(subq_37.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_27.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC('day', ds) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > subq_24.ds__day - INTERVAL 7 day + subq_30.ds__day > subq_33.ds__day - INTERVAL 7 day ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0.sql index 9076e7b4f8..82a7510472 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0.sql @@ -1,376 +1,376 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - , subq_2.visit__referrer_id - ) subq_3 + subq_11.metric_time__day + , subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > subq_9.ds__day - INTERVAL 7 day + subq_15.ds__day > subq_18.ds__day - INTERVAL 7 day ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.metric_time__day - , subq_12.visit__referrer_id - ) subq_13 + subq_21.metric_time__day + , subq_21.visit__referrer_id + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0_optimized.sql index 3326904f31..37da344ff8 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/DuckDB/test_conversion_rate_with_window__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,13 +41,13 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -58,8 +58,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -69,30 +69,30 @@ FROM ( , user_id AS user , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > subq_24.ds__day - INTERVAL 7 day + subq_30.ds__day > subq_33.ds__day - INTERVAL 7 day ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0.sql index cbcb901362..bd032d14dd 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - subq_14.buys AS visit_buy_conversions + subq_23.buys AS visit_buy_conversions FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , COALESCE(MAX(subq_13.buys), 0) AS buys + MAX(subq_12.visits) AS visits + , COALESCE(MAX(subq_22.buys), 0) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > subq_9.ds__day - MAKE_INTERVAL(days => 7) + subq_15.ds__day > subq_18.ds__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0_optimized.sql index 4d352843c1..4b4e6dbe47 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_count_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions + COALESCE(MAX(subq_37.buys), 0) AS visit_buy_conversions FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC('day', ds) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > subq_24.ds__day - MAKE_INTERVAL(days => 7) + subq_30.ds__day > subq_33.ds__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0.sql index bb7adec3fe..52506786a2 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0.sql @@ -1,352 +1,356 @@ -- Compute Metrics via Expressions SELECT - subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate + subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT - subq_1.visit__referrer_id - , subq_1.visits + subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.visit__referrer_id - ) subq_3 + subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id'] SELECT - subq_11.visit__referrer_id - , subq_11.buys + subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_10.ds__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON - (subq_6.user = subq_9.user) AND ((subq_6.ds__day <= subq_9.ds__day)) - ) subq_10 - ) subq_11 - ) subq_12 + ( + subq_15.user = subq_18.user + ) AND ( + (subq_15.ds__day <= subq_18.ds__day) + ) + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.visit__referrer_id - ) subq_13 + subq_21.visit__referrer_id + ) subq_22 ON - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id GROUP BY - COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0_optimized.sql index eef0a1bd3a..99731f7c81 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'visit__referrer_id'] @@ -35,12 +35,12 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -50,8 +50,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -61,20 +61,20 @@ FROM ( , user_id AS user , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - (subq_21.ds__day <= subq_24.ds__day) + (subq_30.ds__day <= subq_33.ds__day) ) - ) subq_25 + ) subq_34 GROUP BY visit__referrer_id - ) subq_28 + ) subq_37 ON - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id GROUP BY - COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0.sql index 5fb17d874f..3b6d1e7f71 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0.sql @@ -1,381 +1,381 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_by_session + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_by_session FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - , subq_2.visit__referrer_id - ) subq_3 + subq_11.metric_time__day + , subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.session - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.session + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_6.session) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_15.session) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user', 'session'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.session - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.session + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( - subq_6.session = subq_9.session_id + subq_15.session = subq_18.session_id ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > subq_9.ds__day - MAKE_INTERVAL(days => 7) + subq_15.ds__day > subq_18.ds__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.metric_time__day - , subq_12.visit__referrer_id - ) subq_13 + subq_21.metric_time__day + , subq_21.visit__referrer_id + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0_optimized.sql index cf04b1b14c..a4612a35c1 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_constant_properties__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,14 +41,14 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_21.session) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_30.session) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -60,8 +60,8 @@ FROM ( , session_id AS session , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -72,32 +72,32 @@ FROM ( , session_id , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - subq_21.session = subq_24.session_id + subq_30.session = subq_33.session_id ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > subq_24.ds__day - MAKE_INTERVAL(days => 7) + subq_30.ds__day > subq_33.ds__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0.sql index 9c76d22d39..6b869775fd 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + CAST(subq_23.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > subq_9.ds__day - MAKE_INTERVAL(days => 7) + subq_15.ds__day > subq_18.ds__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0_optimized.sql index cbecf69018..6cf7c39d63 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_28.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_18.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + CAST(MAX(subq_37.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_27.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC('day', ds) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > subq_24.ds__day - MAKE_INTERVAL(days => 7) + subq_30.ds__day > subq_33.ds__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0.sql index 1c26ca1d8e..a63cb8b42d 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0.sql @@ -1,376 +1,376 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - , subq_2.visit__referrer_id - ) subq_3 + subq_11.metric_time__day + , subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(isodow FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(isodow FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(isodow FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(isodow FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > subq_9.ds__day - MAKE_INTERVAL(days => 7) + subq_15.ds__day > subq_18.ds__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.metric_time__day - , subq_12.visit__referrer_id - ) subq_13 + subq_21.metric_time__day + , subq_21.visit__referrer_id + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0_optimized.sql index 9f9740236c..5863366113 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_rate_with_window__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,13 +41,13 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -58,8 +58,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -69,30 +69,30 @@ FROM ( , user_id AS user , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > subq_24.ds__day - MAKE_INTERVAL(days => 7) + subq_30.ds__day > subq_33.ds__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0.sql index ea94c52f9a..144c372b0a 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - subq_14.buys AS visit_buy_conversions + subq_23.buys AS visit_buy_conversions FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , COALESCE(MAX(subq_13.buys), 0) AS buys + MAX(subq_12.visits) AS visits + , COALESCE(MAX(subq_22.buys), 0) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM buys_source_src_28002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28002.ds) END AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , CASE WHEN EXTRACT(dow FROM buys_source_src_28002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28002.ds) END AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28000.ds) END AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + subq_15.ds__day > DATEADD(day, -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0_optimized.sql index 186b31c974..f79318dd55 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_count_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions + COALESCE(MAX(subq_37.buys), 0) AS visit_buy_conversions FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC('day', ds) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + subq_30.ds__day > DATEADD(day, -7, subq_33.ds__day) ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0.sql index dd5dda5d57..7720eb0a6c 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0.sql @@ -1,352 +1,356 @@ -- Compute Metrics via Expressions SELECT - subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate + subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT - subq_1.visit__referrer_id - , subq_1.visits + subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.visit__referrer_id - ) subq_3 + subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id'] SELECT - subq_11.visit__referrer_id - , subq_11.buys + subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_10.ds__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM buys_source_src_28002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28002.ds) END AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , CASE WHEN EXTRACT(dow FROM buys_source_src_28002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28002.ds) END AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28000.ds) END AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON - (subq_6.user = subq_9.user) AND ((subq_6.ds__day <= subq_9.ds__day)) - ) subq_10 - ) subq_11 - ) subq_12 + ( + subq_15.user = subq_18.user + ) AND ( + (subq_15.ds__day <= subq_18.ds__day) + ) + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.visit__referrer_id - ) subq_13 + subq_21.visit__referrer_id + ) subq_22 ON - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id GROUP BY - COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0_optimized.sql index 90b1250d8a..aa5cf0eb43 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'visit__referrer_id'] @@ -35,12 +35,12 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -50,8 +50,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -61,20 +61,20 @@ FROM ( , user_id AS user , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - (subq_21.ds__day <= subq_24.ds__day) + (subq_30.ds__day <= subq_33.ds__day) ) - ) subq_25 + ) subq_34 GROUP BY visit__referrer_id - ) subq_28 + ) subq_37 ON - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id GROUP BY - COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0.sql index f172695f8d..315527076e 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0.sql @@ -1,381 +1,381 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_by_session + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_by_session FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - , subq_2.visit__referrer_id - ) subq_3 + subq_11.metric_time__day + , subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.session - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.session + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_6.session) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_15.session) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user', 'session'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.session - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.session + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM buys_source_src_28002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28002.ds) END AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , CASE WHEN EXTRACT(dow FROM buys_source_src_28002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28002.ds) END AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28000.ds) END AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( - subq_6.session = subq_9.session_id + subq_15.session = subq_18.session_id ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + subq_15.ds__day > DATEADD(day, -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.metric_time__day - , subq_12.visit__referrer_id - ) subq_13 + subq_21.metric_time__day + , subq_21.visit__referrer_id + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0_optimized.sql index 196158ae82..52617b047f 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_constant_properties__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,14 +41,14 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_21.session) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_30.session) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -60,8 +60,8 @@ FROM ( , session_id AS session , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -72,32 +72,32 @@ FROM ( , session_id , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - subq_21.session = subq_24.session_id + subq_30.session = subq_33.session_id ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + subq_30.ds__day > DATEADD(day, -7, subq_33.ds__day) ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0.sql index ed6d1ba541..707284ce04 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + CAST(subq_23.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM buys_source_src_28002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28002.ds) END AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , CASE WHEN EXTRACT(dow FROM buys_source_src_28002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28002.ds) END AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28000.ds) END AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + subq_15.ds__day > DATEADD(day, -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0_optimized.sql index 797aac359e..becf445ac2 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_28.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_18.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + CAST(MAX(subq_37.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_27.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC('day', ds) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + subq_30.ds__day > DATEADD(day, -7, subq_33.ds__day) ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0.sql index b95b5f3ac4..4666a59a48 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0.sql @@ -1,376 +1,376 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - , subq_2.visit__referrer_id - ) subq_3 + subq_11.metric_time__day + , subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , CASE WHEN EXTRACT(dow FROM visits_source_src_28011.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28011.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28011.ds) END AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , CASE WHEN EXTRACT(dow FROM visits_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM visits_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM visits_source_src_28000.ds) END AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM buys_source_src_28002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28002.ds) END AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , CASE WHEN EXTRACT(dow FROM buys_source_src_28002.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28002.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28002.ds) END AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , CASE WHEN EXTRACT(dow FROM buys_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM buys_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM buys_source_src_28000.ds) END AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + subq_15.ds__day > DATEADD(day, -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.metric_time__day - , subq_12.visit__referrer_id - ) subq_13 + subq_21.metric_time__day + , subq_21.visit__referrer_id + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0_optimized.sql index ce5b8ae2a9..34afc895d8 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_rate_with_window__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,13 +41,13 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -58,8 +58,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -69,30 +69,30 @@ FROM ( , user_id AS user , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + subq_30.ds__day > DATEADD(day, -7, subq_33.ds__day) ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0.sql index 29fddc3aad..565162a453 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - subq_14.buys AS visit_buy_conversions + subq_23.buys AS visit_buy_conversions FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , COALESCE(MAX(subq_13.buys), 0) AS buys + MAX(subq_12.visits) AS visits + , COALESCE(MAX(subq_22.buys), 0) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , UUID_STRING() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(dayofweekiso FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + subq_15.ds__day > DATEADD(day, -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0_optimized.sql index a49f83324a..a476f2d738 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_count_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions + COALESCE(MAX(subq_37.buys), 0) AS visit_buy_conversions FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC('day', ds) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , UUID_STRING() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + subq_30.ds__day > DATEADD(day, -7, subq_33.ds__day) ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0.sql index 162684165c..6e9b8afa69 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0.sql @@ -1,352 +1,356 @@ -- Compute Metrics via Expressions SELECT - subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate + subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT - subq_1.visit__referrer_id - , subq_1.visits + subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.visit__referrer_id - ) subq_3 + subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id'] SELECT - subq_11.visit__referrer_id - , subq_11.buys + subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_10.ds__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , UUID_STRING() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(dayofweekiso FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON - (subq_6.user = subq_9.user) AND ((subq_6.ds__day <= subq_9.ds__day)) - ) subq_10 - ) subq_11 - ) subq_12 + ( + subq_15.user = subq_18.user + ) AND ( + (subq_15.ds__day <= subq_18.ds__day) + ) + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.visit__referrer_id - ) subq_13 + subq_21.visit__referrer_id + ) subq_22 ON - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id GROUP BY - COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0_optimized.sql index 2504974b1b..07a93f8911 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'visit__referrer_id'] @@ -35,12 +35,12 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -50,8 +50,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -61,20 +61,20 @@ FROM ( , user_id AS user , 1 AS buys , UUID_STRING() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - (subq_21.ds__day <= subq_24.ds__day) + (subq_30.ds__day <= subq_33.ds__day) ) - ) subq_25 + ) subq_34 GROUP BY visit__referrer_id - ) subq_28 + ) subq_37 ON - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id GROUP BY - COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0.sql index 771fa3ef07..769cb97ec8 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0.sql @@ -1,381 +1,381 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - , subq_2.visit__referrer_id - ) subq_3 + subq_11.metric_time__day + , subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.session - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.session + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_6.session) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_15.session) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user', 'session'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.session - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.session + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , UUID_STRING() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(dayofweekiso FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( - subq_6.session = subq_9.session_id + subq_15.session = subq_18.session_id ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + subq_15.ds__day > DATEADD(day, -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.metric_time__day - , subq_12.visit__referrer_id - ) subq_13 + subq_21.metric_time__day + , subq_21.visit__referrer_id + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0_optimized.sql index 2f27e70af7..0af52ccf3c 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_constant_properties__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,14 +41,14 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_21.session) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_30.session) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -60,8 +60,8 @@ FROM ( , session_id AS session , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -72,32 +72,32 @@ FROM ( , session_id , 1 AS buys , UUID_STRING() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - subq_21.session = subq_24.session_id + subq_30.session = subq_33.session_id ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + subq_30.ds__day > DATEADD(day, -7, subq_33.ds__day) ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0.sql index 61f5e44e8d..437ddbddd7 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , UUID_STRING() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(dayofweekiso FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + subq_15.ds__day > DATEADD(day, -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0_optimized.sql index fbabe42a69..ce240491c7 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_28.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_18.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(MAX(subq_37.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_27.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC('day', ds) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , UUID_STRING() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + subq_30.ds__day > DATEADD(day, -7, subq_33.ds__day) ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0.sql index fa3e3e894a..97965eede6 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0.sql @@ -1,376 +1,376 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - , subq_2.visit__referrer_id - ) subq_3 + subq_11.metric_time__day + , subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(dayofweekiso FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(dayofweekiso FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , UUID_STRING() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(dayofweekiso FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(dayofweekiso FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATEADD(day, -7, subq_9.ds__day) + subq_15.ds__day > DATEADD(day, -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.metric_time__day - , subq_12.visit__referrer_id - ) subq_13 + subq_21.metric_time__day + , subq_21.visit__referrer_id + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0_optimized.sql index e90128a078..5875f64bfb 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_rate_with_window__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,13 +41,13 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -58,8 +58,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -69,30 +69,30 @@ FROM ( , user_id AS user , 1 AS buys , UUID_STRING() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATEADD(day, -7, subq_24.ds__day) + subq_30.ds__day > DATEADD(day, -7, subq_33.ds__day) ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_count_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_count_with_no_group_by__plan0.sql index bde01927ff..bd284f3160 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_count_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_count_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - subq_14.buys AS visit_buy_conversions + subq_23.buys AS visit_buy_conversions FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , COALESCE(MAX(subq_13.buys), 0) AS buys + MAX(subq_12.visits) AS visits + , COALESCE(MAX(subq_22.buys), 0) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , uuid() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATE_ADD('day', -7, subq_9.ds__day) + subq_15.ds__day > DATE_ADD('day', -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_count_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_count_with_no_group_by__plan0_optimized.sql index 0e456f0b75..93122a23dd 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_count_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_count_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions + COALESCE(MAX(subq_37.buys), 0) AS visit_buy_conversions FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC('day', ds) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , uuid() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATE_ADD('day', -7, subq_24.ds__day) + subq_30.ds__day > DATE_ADD('day', -7, subq_33.ds__day) ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate__plan0.sql index c8f7ec4221..56179a58c0 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate__plan0.sql @@ -1,352 +1,356 @@ -- Compute Metrics via Expressions SELECT - subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate + subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT - subq_1.visit__referrer_id - , subq_1.visits + subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.visit__referrer_id - ) subq_3 + subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id'] SELECT - subq_11.visit__referrer_id - , subq_11.buys + subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_10.ds__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , uuid() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON - (subq_6.user = subq_9.user) AND ((subq_6.ds__day <= subq_9.ds__day)) - ) subq_10 - ) subq_11 - ) subq_12 + ( + subq_15.user = subq_18.user + ) AND ( + (subq_15.ds__day <= subq_18.ds__day) + ) + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.visit__referrer_id - ) subq_13 + subq_21.visit__referrer_id + ) subq_22 ON - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id GROUP BY - COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate__plan0_optimized.sql index c2d5f1e7d3..c893747aae 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'visit__referrer_id'] @@ -35,12 +35,12 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -50,8 +50,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -61,20 +61,20 @@ FROM ( , user_id AS user , 1 AS buys , uuid() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - (subq_21.ds__day <= subq_24.ds__day) + (subq_30.ds__day <= subq_33.ds__day) ) - ) subq_25 + ) subq_34 GROUP BY visit__referrer_id - ) subq_28 + ) subq_37 ON - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id GROUP BY - COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_constant_properties__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_constant_properties__plan0.sql index 430ed15ad4..9999b30328 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_constant_properties__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_constant_properties__plan0.sql @@ -1,381 +1,381 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_by_session FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - , subq_2.visit__referrer_id - ) subq_3 + subq_11.metric_time__day + , subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.session - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.session + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_6.session) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid, subq_9.session_id ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_15.session) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid, subq_18.session_id ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user', 'session'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.session - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.session + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , uuid() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( - subq_6.session = subq_9.session_id + subq_15.session = subq_18.session_id ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATE_ADD('day', -7, subq_9.ds__day) + subq_15.ds__day > DATE_ADD('day', -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.metric_time__day - , subq_12.visit__referrer_id - ) subq_13 + subq_21.metric_time__day + , subq_21.visit__referrer_id + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_constant_properties__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_constant_properties__plan0_optimized.sql index 5e9b77c8ca..f2c83ba8a1 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_constant_properties__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_constant_properties__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,14 +41,14 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , first_value(subq_21.session) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid, subq_24.session_id ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , first_value(subq_30.session) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid, subq_33.session_id ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS session + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -60,8 +60,8 @@ FROM ( , session_id AS session , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -72,32 +72,32 @@ FROM ( , session_id , 1 AS buys , uuid() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( - subq_21.session = subq_24.session_id + subq_30.session = subq_33.session_id ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATE_ADD('day', -7, subq_24.ds__day) + subq_30.ds__day > DATE_ADD('day', -7, subq_33.ds__day) ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_no_group_by__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_no_group_by__plan0.sql index 995a089d04..5794883bd1 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_no_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_no_group_by__plan0.sql @@ -1,343 +1,343 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_2.visits) AS visits + SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_1.visits + subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_12.buys) AS buys + SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_11.buys + subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.user - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.user + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_5.ds__day - , subq_5.user - , subq_5.visits + subq_14.ds__day + , subq_14.user + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , uuid() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATE_ADD('day', -7, subq_9.ds__day) + subq_15.ds__day > DATE_ADD('day', -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 - ) subq_13 -) subq_14 + ) subq_19 + ) subq_20 + ) subq_21 + ) subq_22 +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_no_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_no_group_by__plan0_optimized.sql index 682b934bef..1e00e0579a 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_no_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_no_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_28.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_18.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(MAX(subq_37.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_27.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -9,8 +9,8 @@ FROM ( -- Aggregate Measures SELECT SUM(1) AS visits - FROM ***************************.fct_visits visits_source_src_28011 -) subq_18 + FROM ***************************.fct_visits visits_source_src_28000 +) subq_27 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -20,11 +20,11 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -33,8 +33,8 @@ CROSS JOIN ( DATE_TRUNC('day', ds) AS ds__day , user_id AS user , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -44,17 +44,17 @@ CROSS JOIN ( , user_id AS user , 1 AS buys , uuid() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATE_ADD('day', -7, subq_24.ds__day) + subq_30.ds__day > DATE_ADD('day', -7, subq_33.ds__day) ) ) - ) subq_25 -) subq_28 + ) subq_34 +) subq_37 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_window__plan0.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_window__plan0.sql index 7057a05216..a6a2646be3 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_window__plan0.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_window__plan0.sql @@ -1,376 +1,376 @@ -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.visit__referrer_id - , CAST(subq_14.buys AS DOUBLE) / CAST(NULLIF(subq_14.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_23.metric_time__day + , subq_23.visit__referrer_id + , CAST(subq_23.buys AS DOUBLE) / CAST(NULLIF(subq_23.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) AS metric_time__day - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) AS visit__referrer_id - , MAX(subq_3.visits) AS visits - , MAX(subq_13.buys) AS buys + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) AS visit__referrer_id + , MAX(subq_12.visits) AS visits + , MAX(subq_22.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , subq_2.visit__referrer_id - , SUM(subq_2.visits) AS visits + subq_11.metric_time__day + , subq_11.visit__referrer_id + , SUM(subq_11.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.visit__referrer_id - , subq_1.visits + subq_10.metric_time__day + , subq_10.visit__referrer_id + , subq_10.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.visit__ds__day + , subq_9.visit__ds__week + , subq_9.visit__ds__month + , subq_9.visit__ds__quarter + , subq_9.visit__ds__year + , subq_9.visit__ds__extract_year + , subq_9.visit__ds__extract_quarter + , subq_9.visit__ds__extract_month + , subq_9.visit__ds__extract_day + , subq_9.visit__ds__extract_dow + , subq_9.visit__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.session + , subq_9.visit__user + , subq_9.visit__session + , subq_9.referrer_id + , subq_9.visit__referrer_id + , subq_9.visits + , subq_9.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_0 - ) subq_1 - ) subq_2 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - , subq_2.visit__referrer_id - ) subq_3 + subq_11.metric_time__day + , subq_11.visit__referrer_id + ) subq_12 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.visit__referrer_id - , SUM(subq_12.buys) AS buys + subq_21.metric_time__day + , subq_21.visit__referrer_id + , SUM(subq_21.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.visit__referrer_id - , subq_11.buys + subq_20.metric_time__day + , subq_20.visit__referrer_id + , subq_20.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_10.ds__day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visit__referrer_id - , subq_10.buys - , subq_10.visits + subq_19.ds__day + , subq_19.metric_time__day + , subq_19.user + , subq_19.visit__referrer_id + , subq_19.buys + , subq_19.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_6.visits) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_6.visit__referrer_id) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_6.ds__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_6.metric_time__day) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_6.user) OVER (PARTITION BY subq_9.user, subq_9.ds__day, subq_9.mf_internal_uuid ORDER BY subq_6.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_9.mf_internal_uuid AS mf_internal_uuid - , subq_9.buys AS buys + first_value(subq_15.visits) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_15.visit__referrer_id) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_15.ds__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_15.metric_time__day) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_15.user) OVER (PARTITION BY subq_18.user, subq_18.ds__day, subq_18.mf_internal_uuid ORDER BY subq_15.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_18.mf_internal_uuid AS mf_internal_uuid + , subq_18.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] SELECT - subq_5.ds__day - , subq_5.metric_time__day - , subq_5.user - , subq_5.visit__referrer_id - , subq_5.visits + subq_14.ds__day + , subq_14.metric_time__day + , subq_14.user + , subq_14.visit__referrer_id + , subq_14.visits FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.visit__ds__day + , subq_13.visit__ds__week + , subq_13.visit__ds__month + , subq_13.visit__ds__quarter + , subq_13.visit__ds__year + , subq_13.visit__ds__extract_year + , subq_13.visit__ds__extract_quarter + , subq_13.visit__ds__extract_month + , subq_13.visit__ds__extract_day + , subq_13.visit__ds__extract_dow + , subq_13.visit__ds__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.user + , subq_13.session + , subq_13.visit__user + , subq_13.visit__session + , subq_13.referrer_id + , subq_13.visit__referrer_id + , subq_13.visits + , subq_13.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT 1 AS visits - , visits_source_src_28011.user_id AS visitors - , DATE_TRUNC('day', visits_source_src_28011.ds) AS ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS ds__extract_doy - , visits_source_src_28011.referrer_id - , DATE_TRUNC('day', visits_source_src_28011.ds) AS visit__ds__day - , DATE_TRUNC('week', visits_source_src_28011.ds) AS visit__ds__week - , DATE_TRUNC('month', visits_source_src_28011.ds) AS visit__ds__month - , DATE_TRUNC('quarter', visits_source_src_28011.ds) AS visit__ds__quarter - , DATE_TRUNC('year', visits_source_src_28011.ds) AS visit__ds__year - , EXTRACT(year FROM visits_source_src_28011.ds) AS visit__ds__extract_year - , EXTRACT(quarter FROM visits_source_src_28011.ds) AS visit__ds__extract_quarter - , EXTRACT(month FROM visits_source_src_28011.ds) AS visit__ds__extract_month - , EXTRACT(day FROM visits_source_src_28011.ds) AS visit__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28011.ds) AS visit__ds__extract_dow - , EXTRACT(doy FROM visits_source_src_28011.ds) AS visit__ds__extract_doy - , visits_source_src_28011.referrer_id AS visit__referrer_id - , visits_source_src_28011.user_id AS user - , visits_source_src_28011.session_id AS session - , visits_source_src_28011.user_id AS visit__user - , visits_source_src_28011.session_id AS visit__session - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_4 - ) subq_5 - ) subq_6 + , visits_source_src_28000.user_id AS visitors + , DATE_TRUNC('day', visits_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS ds__extract_doy + , visits_source_src_28000.referrer_id + , DATE_TRUNC('day', visits_source_src_28000.ds) AS visit__ds__day + , DATE_TRUNC('week', visits_source_src_28000.ds) AS visit__ds__week + , DATE_TRUNC('month', visits_source_src_28000.ds) AS visit__ds__month + , DATE_TRUNC('quarter', visits_source_src_28000.ds) AS visit__ds__quarter + , DATE_TRUNC('year', visits_source_src_28000.ds) AS visit__ds__year + , EXTRACT(year FROM visits_source_src_28000.ds) AS visit__ds__extract_year + , EXTRACT(quarter FROM visits_source_src_28000.ds) AS visit__ds__extract_quarter + , EXTRACT(month FROM visits_source_src_28000.ds) AS visit__ds__extract_month + , EXTRACT(day FROM visits_source_src_28000.ds) AS visit__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM visits_source_src_28000.ds) AS visit__ds__extract_dow + , EXTRACT(doy FROM visits_source_src_28000.ds) AS visit__ds__extract_doy + , visits_source_src_28000.referrer_id AS visit__referrer_id + , visits_source_src_28000.user_id AS user + , visits_source_src_28000.session_id AS session + , visits_source_src_28000.user_id AS visit__user + , visits_source_src_28000.session_id AS visit__session + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_13 + ) subq_14 + ) subq_15 INNER JOIN ( -- Add column with generated UUID SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.buy__ds__day - , subq_8.buy__ds__week - , subq_8.buy__ds__month - , subq_8.buy__ds__quarter - , subq_8.buy__ds__year - , subq_8.buy__ds__extract_year - , subq_8.buy__ds__extract_quarter - , subq_8.buy__ds__extract_month - , subq_8.buy__ds__extract_day - , subq_8.buy__ds__extract_dow - , subq_8.buy__ds__extract_doy - , subq_8.metric_time__day - , subq_8.metric_time__week - , subq_8.metric_time__month - , subq_8.metric_time__quarter - , subq_8.metric_time__year - , subq_8.metric_time__extract_year - , subq_8.metric_time__extract_quarter - , subq_8.metric_time__extract_month - , subq_8.metric_time__extract_day - , subq_8.metric_time__extract_dow - , subq_8.metric_time__extract_doy - , subq_8.user - , subq_8.session_id - , subq_8.buy__user - , subq_8.buy__session_id - , subq_8.buys - , subq_8.buyers + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.buy__ds__day + , subq_17.buy__ds__week + , subq_17.buy__ds__month + , subq_17.buy__ds__quarter + , subq_17.buy__ds__year + , subq_17.buy__ds__extract_year + , subq_17.buy__ds__extract_quarter + , subq_17.buy__ds__extract_month + , subq_17.buy__ds__extract_day + , subq_17.buy__ds__extract_dow + , subq_17.buy__ds__extract_doy + , subq_17.metric_time__day + , subq_17.metric_time__week + , subq_17.metric_time__month + , subq_17.metric_time__quarter + , subq_17.metric_time__year + , subq_17.metric_time__extract_year + , subq_17.metric_time__extract_quarter + , subq_17.metric_time__extract_month + , subq_17.metric_time__extract_day + , subq_17.metric_time__extract_dow + , subq_17.metric_time__extract_doy + , subq_17.user + , subq_17.session_id + , subq_17.buy__user + , subq_17.buy__session_id + , subq_17.buys + , subq_17.buyers , uuid() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.buy__ds__day - , subq_7.buy__ds__week - , subq_7.buy__ds__month - , subq_7.buy__ds__quarter - , subq_7.buy__ds__year - , subq_7.buy__ds__extract_year - , subq_7.buy__ds__extract_quarter - , subq_7.buy__ds__extract_month - , subq_7.buy__ds__extract_day - , subq_7.buy__ds__extract_dow - , subq_7.buy__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session_id - , subq_7.buy__user - , subq_7.buy__session_id - , subq_7.buys - , subq_7.buyers + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.buy__ds__day + , subq_16.buy__ds__week + , subq_16.buy__ds__month + , subq_16.buy__ds__quarter + , subq_16.buy__ds__year + , subq_16.buy__ds__extract_year + , subq_16.buy__ds__extract_quarter + , subq_16.buy__ds__extract_month + , subq_16.buy__ds__extract_day + , subq_16.buy__ds__extract_dow + , subq_16.buy__ds__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.user + , subq_16.session_id + , subq_16.buy__user + , subq_16.buy__session_id + , subq_16.buys + , subq_16.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT 1 AS buys - , buys_source_src_28002.user_id AS buyers - , DATE_TRUNC('day', buys_source_src_28002.ds) AS ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28002.ds) AS ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS ds__extract_doy - , DATE_TRUNC('day', buys_source_src_28002.ds) AS buy__ds__day - , DATE_TRUNC('week', buys_source_src_28002.ds) AS buy__ds__week - , DATE_TRUNC('month', buys_source_src_28002.ds) AS buy__ds__month - , DATE_TRUNC('quarter', buys_source_src_28002.ds) AS buy__ds__quarter - , DATE_TRUNC('year', buys_source_src_28002.ds) AS buy__ds__year - , EXTRACT(year FROM buys_source_src_28002.ds) AS buy__ds__extract_year - , EXTRACT(quarter FROM buys_source_src_28002.ds) AS buy__ds__extract_quarter - , EXTRACT(month FROM buys_source_src_28002.ds) AS buy__ds__extract_month - , EXTRACT(day FROM buys_source_src_28002.ds) AS buy__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28002.ds) AS buy__ds__extract_dow - , EXTRACT(doy FROM buys_source_src_28002.ds) AS buy__ds__extract_doy - , buys_source_src_28002.user_id AS user - , buys_source_src_28002.session_id - , buys_source_src_28002.user_id AS buy__user - , buys_source_src_28002.session_id AS buy__session_id - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_7 - ) subq_8 - ) subq_9 + , buys_source_src_28000.user_id AS buyers + , DATE_TRUNC('day', buys_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', buys_source_src_28000.ds) AS buy__ds__day + , DATE_TRUNC('week', buys_source_src_28000.ds) AS buy__ds__week + , DATE_TRUNC('month', buys_source_src_28000.ds) AS buy__ds__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds) AS buy__ds__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds) AS buy__ds__year + , EXTRACT(year FROM buys_source_src_28000.ds) AS buy__ds__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds) AS buy__ds__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds) AS buy__ds__extract_month + , EXTRACT(day FROM buys_source_src_28000.ds) AS buy__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM buys_source_src_28000.ds) AS buy__ds__extract_dow + , EXTRACT(doy FROM buys_source_src_28000.ds) AS buy__ds__extract_doy + , buys_source_src_28000.user_id AS user + , buys_source_src_28000.session_id + , buys_source_src_28000.user_id AS buy__user + , buys_source_src_28000.session_id AS buy__session_id + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_16 + ) subq_17 + ) subq_18 ON ( - subq_6.user = subq_9.user + subq_15.user = subq_18.user ) AND ( ( - subq_6.ds__day <= subq_9.ds__day + subq_15.ds__day <= subq_18.ds__day ) AND ( - subq_6.ds__day > DATE_ADD('day', -7, subq_9.ds__day) + subq_15.ds__day > DATE_ADD('day', -7, subq_18.ds__day) ) ) - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_19 + ) subq_20 + ) subq_21 GROUP BY - subq_12.metric_time__day - , subq_12.visit__referrer_id - ) subq_13 + subq_21.metric_time__day + , subq_21.visit__referrer_id + ) subq_22 ON ( - subq_3.visit__referrer_id = subq_13.visit__referrer_id + subq_12.visit__referrer_id = subq_22.visit__referrer_id ) AND ( - subq_3.metric_time__day = subq_13.metric_time__day + subq_12.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_3.metric_time__day, subq_13.metric_time__day) - , COALESCE(subq_3.visit__referrer_id, subq_13.visit__referrer_id) -) subq_14 + COALESCE(subq_12.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_12.visit__referrer_id, subq_22.visit__referrer_id) +) subq_23 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_window__plan0_optimized.sql b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_window__plan0_optimized.sql index 8eb1daea87..6452e95658 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_rate_with_window__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) AS visit__referrer_id - , MAX(subq_18.visits) AS visits - , MAX(subq_28.buys) AS buys + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) AS visit__referrer_id + , MAX(subq_27.visits) AS visits + , MAX(subq_37.buys) AS buys FROM ( -- Aggregate Measures SELECT @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_17 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_26 GROUP BY metric_time__day , visit__referrer_id - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -41,13 +41,13 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits - , first_value(subq_21.visit__referrer_id) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id - , first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day - , first_value(subq_21.metric_time__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day - , first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user - , subq_24.mf_internal_uuid AS mf_internal_uuid - , subq_24.buys AS buys + first_value(subq_30.visits) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits + , first_value(subq_30.visit__referrer_id) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visit__referrer_id + , first_value(subq_30.ds__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day + , first_value(subq_30.metric_time__day) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS metric_time__day + , first_value(subq_30.user) OVER (PARTITION BY subq_33.user, subq_33.ds__day, subq_33.mf_internal_uuid ORDER BY subq_30.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user + , subq_33.mf_internal_uuid AS mf_internal_uuid + , subq_33.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -58,8 +58,8 @@ FROM ( , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits - FROM ***************************.fct_visits visits_source_src_28011 - ) subq_21 + FROM ***************************.fct_visits visits_source_src_28000 + ) subq_30 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -69,30 +69,30 @@ FROM ( , user_id AS user , 1 AS buys , uuid() AS mf_internal_uuid - FROM ***************************.fct_buys buys_source_src_28002 - ) subq_24 + FROM ***************************.fct_buys buys_source_src_28000 + ) subq_33 ON ( - subq_21.user = subq_24.user + subq_30.user = subq_33.user ) AND ( ( - subq_21.ds__day <= subq_24.ds__day + subq_30.ds__day <= subq_33.ds__day ) AND ( - subq_21.ds__day > DATE_ADD('day', -7, subq_24.ds__day) + subq_30.ds__day > DATE_ADD('day', -7, subq_33.ds__day) ) ) - ) subq_25 + ) subq_34 GROUP BY metric_time__day , visit__referrer_id - ) subq_28 + ) subq_37 ON ( - subq_18.visit__referrer_id = subq_28.visit__referrer_id + subq_27.visit__referrer_id = subq_37.visit__referrer_id ) AND ( - subq_18.metric_time__day = subq_28.metric_time__day + subq_27.metric_time__day = subq_37.metric_time__day ) GROUP BY - COALESCE(subq_18.metric_time__day, subq_28.metric_time__day) - , COALESCE(subq_18.visit__referrer_id, subq_28.visit__referrer_id) -) subq_29 + COALESCE(subq_27.metric_time__day, subq_37.metric_time__day) + , COALESCE(subq_27.visit__referrer_id, subq_37.visit__referrer_id) +) subq_38 diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml index 40cac96747..5902310e23 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml @@ -24,7 +24,7 @@ - + @@ -455,7 +455,7 @@ - + diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml index 4ac7e33117..42b580d16d 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml @@ -31,7 +31,7 @@ - + @@ -508,7 +508,7 @@ - + diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml index 736288efbe..399c26d29e 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml @@ -40,7 +40,7 @@ - + @@ -557,7 +557,7 @@ - + diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml index 43bf25c535..39b10525f7 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml @@ -27,7 +27,7 @@ - + @@ -458,7 +458,7 @@ - + diff --git a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml index 0256177bd2..d4e40a289d 100644 --- a/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml +++ b/metricflow/test/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml @@ -40,7 +40,7 @@ - + @@ -550,7 +550,7 @@ - + diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_query_semantic_model__plan0.sql index 4e4162cf69..62bd3fea5e 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_query_semantic_model__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_28007.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_28007.created_at, day) AS revenue_instance__ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS revenue_instance__ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS revenue_instance__ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS revenue_instance__ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS revenue_instance__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user -FROM ***************************.fct_revenue revenue_src_28007 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_28000.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_28000.created_at, day) AS revenue_instance__ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS revenue_instance__ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS revenue_instance__ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS revenue_instance__ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS revenue_instance__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_with_measures__plan0.sql index becf4eae22..879c6b43f7 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,53 +1,53 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC(id_verifications_src_28004.ds, day) AS ds__day - , DATE_TRUNC(id_verifications_src_28004.ds, isoweek) AS ds__week - , DATE_TRUNC(id_verifications_src_28004.ds, month) AS ds__month - , DATE_TRUNC(id_verifications_src_28004.ds, quarter) AS ds__quarter - , DATE_TRUNC(id_verifications_src_28004.ds, year) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_28004.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28004.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_28004.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28004.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC(id_verifications_src_28004.ds, day) AS verification__ds__day - , DATE_TRUNC(id_verifications_src_28004.ds, isoweek) AS verification__ds__week - , DATE_TRUNC(id_verifications_src_28004.ds, month) AS verification__ds__month - , DATE_TRUNC(id_verifications_src_28004.ds, quarter) AS verification__ds__quarter - , DATE_TRUNC(id_verifications_src_28004.ds, year) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_28004.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28004.ds) - 1) AS verification__ds__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, day) AS verification__ds_partitioned__day - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, isoweek) AS verification__ds_partitioned__week - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, month) AS verification__ds_partitioned__month - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, quarter) AS verification__ds_partitioned__quarter - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, year) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_28004.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28004.ds_partitioned) - 1) AS verification__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user -FROM ***************************.fct_id_verifications id_verifications_src_28004 + , DATE_TRUNC(id_verifications_src_28000.ds, day) AS ds__day + , DATE_TRUNC(id_verifications_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(id_verifications_src_28000.ds, month) AS ds__month + , DATE_TRUNC(id_verifications_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(id_verifications_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC(id_verifications_src_28000.ds, day) AS verification__ds__day + , DATE_TRUNC(id_verifications_src_28000.ds, isoweek) AS verification__ds__week + , DATE_TRUNC(id_verifications_src_28000.ds, month) AS verification__ds__month + , DATE_TRUNC(id_verifications_src_28000.ds, quarter) AS verification__ds__quarter + , DATE_TRUNC(id_verifications_src_28000.ds, year) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28000.ds) - 1) AS verification__ds__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, day) AS verification__ds_partitioned__day + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, isoweek) AS verification__ds_partitioned__week + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, month) AS verification__ds_partitioned__month + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, quarter) AS verification__ds_partitioned__quarter + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, year) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28000.ds_partitioned) - 1) AS verification__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user +FROM ***************************.fct_id_verifications id_verifications_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_without_measures__plan0.sql index e9fce66c32..20f253203a 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_28009.ds, day) AS ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC(users_latest_src_28009.ds, day) AS user__ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS user__ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS user__ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS user__ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user -FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_query_semantic_model__plan0.sql index da22c65a68..2d90fd9d75 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_query_semantic_model__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user -FROM ***************************.fct_revenue revenue_src_28007 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_with_measures__plan0.sql index b8aab0fa4f..69baac5f43 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,53 +1,53 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28004.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28004.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user -FROM ***************************.fct_id_verifications id_verifications_src_28004 + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28000.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user +FROM ***************************.fct_id_verifications id_verifications_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_without_measures__plan0.sql index b5f9e4bc6c..565bd5f4f0 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user -FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_query_semantic_model__plan0.sql index 93878ce423..fb7e89c2c9 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_query_semantic_model__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user -FROM ***************************.fct_revenue revenue_src_28007 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_with_measures__plan0.sql index b98864646d..e05f176f0d 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,53 +1,53 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user -FROM ***************************.fct_id_verifications id_verifications_src_28004 + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user +FROM ***************************.fct_id_verifications id_verifications_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_without_measures__plan0.sql index f0423bde3c..ac68907b77 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user -FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_query_semantic_model__plan0.sql index 93878ce423..fb7e89c2c9 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_query_semantic_model__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user -FROM ***************************.fct_revenue revenue_src_28007 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_with_measures__plan0.sql index b98864646d..e05f176f0d 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,53 +1,53 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user -FROM ***************************.fct_id_verifications id_verifications_src_28004 + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user +FROM ***************************.fct_id_verifications id_verifications_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_without_measures__plan0.sql index f0423bde3c..ac68907b77 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user -FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_query_semantic_model__plan0.sql index ca527146f8..111741670d 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_query_semantic_model__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user -FROM ***************************.fct_revenue revenue_src_28007 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_with_measures__plan0.sql index 29b9a9ebb4..a447b8d7ee 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,53 +1,53 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_28004.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_28004.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28004.ds) END AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_28004.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_28004.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28004.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_28004.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_28004.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28004.ds) END AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_28004.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_28004.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28004.ds_partitioned) END AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user -FROM ***************************.fct_id_verifications id_verifications_src_28004 + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_28000.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_28000.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_28000.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_28000.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28000.ds) END AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28000.ds_partitioned) END AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user +FROM ***************************.fct_id_verifications id_verifications_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_without_measures__plan0.sql index e6266dac25..462d46fffe 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user -FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_query_semantic_model__plan0.sql index c6919f64f9..6b9b65c844 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_query_semantic_model__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user -FROM ***************************.fct_revenue revenue_src_28007 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_with_measures__plan0.sql index 638fa45049..48f4803c55 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,53 +1,53 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_28004.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_28004.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user -FROM ***************************.fct_id_verifications id_verifications_src_28004 + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_28000.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user +FROM ***************************.fct_id_verifications id_verifications_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_without_measures__plan0.sql index bf82f0867b..fc332b8845 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user -FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Trino/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Trino/test_convert_query_semantic_model__plan0.sql index 4c1184dda1..92e117a564 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Trino/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Trino/test_convert_query_semantic_model__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user -FROM ***************************.fct_revenue revenue_src_28007 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Trino/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Trino/test_convert_table_semantic_model_with_measures__plan0.sql index 252f677446..1a6868177f 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Trino/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Trino/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,53 +1,53 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28004.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28004.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user -FROM ***************************.fct_id_verifications id_verifications_src_28004 + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28000.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user +FROM ***************************.fct_id_verifications id_verifications_src_28000 diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Trino/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Trino/test_convert_table_semantic_model_without_measures__plan0.sql index 32ccb4be82..23cdfc8a20 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Trino/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Trino/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,28 +1,28 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user -FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql index ab613c63d2..97bee65651 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.ds__day + , subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__day + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.txn_revenue + subq_10.ds__day + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_28007.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_28007.created_at, day) AS revenue_instance__ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS revenue_instance__ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS revenue_instance__ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS revenue_instance__ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS revenue_instance__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_28000.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_28000.created_at, day) AS revenue_instance__ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS revenue_instance__ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS revenue_instance__ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS revenue_instance__ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS revenue_instance__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY ds__day -) subq_3 +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0_optimized.sql index 2c3fd2a2e6..f1006b1250 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC(created_at, day) AS ds__day , SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY ds__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0.sql index d85715075b..6d61cf0538 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_mtd + subq_12.ds__month + , subq_12.txn_revenue AS revenue_mtd FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_28007.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_28007.created_at, day) AS revenue_instance__ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS revenue_instance__ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS revenue_instance__ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS revenue_instance__ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS revenue_instance__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_28000.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_28000.created_at, day) AS revenue_instance__ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS revenue_instance__ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS revenue_instance__ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS revenue_instance__ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS revenue_instance__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY ds__month -) subq_3 +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0_optimized.sql index 5e75a43a4b..db69f59081 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC(created_at, month) AS ds__month , SUM(revenue) AS revenue_mtd -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY ds__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0.sql index 2cf65b5d0d..ab1e0be55f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0.sql @@ -1,103 +1,103 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.bookings_monthly AS trailing_3_months_bookings + subq_12.metric_time__month + , subq_12.bookings_monthly AS trailing_3_months_bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.bookings_monthly) AS bookings_monthly + subq_11.metric_time__month + , SUM(subq_11.bookings_monthly) AS bookings_monthly FROM ( -- Constrain Time Range to [2020-03-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly + subq_10.metric_time__month + , subq_10.bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.bookings_monthly + subq_9.metric_time__month + , subq_9.bookings_monthly FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.monthly_ds__month AS monthly_ds__month - , subq_2.monthly_ds__quarter AS monthly_ds__quarter - , subq_2.monthly_ds__year AS monthly_ds__year - , subq_2.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_2.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_2.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_2.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_2.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_2.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_2.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_2.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_2.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.listing AS listing - , subq_2.booking__listing AS booking__listing - , subq_2.bookings_monthly AS bookings_monthly + subq_7.metric_time__month AS metric_time__month + , subq_6.monthly_ds__month AS monthly_ds__month + , subq_6.monthly_ds__quarter AS monthly_ds__quarter + , subq_6.monthly_ds__year AS monthly_ds__year + , subq_6.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_6.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_6.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_6.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_6.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_6.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_6.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_6.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_6.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_6.metric_time__quarter AS metric_time__quarter + , subq_6.metric_time__year AS metric_time__year + , subq_6.metric_time__extract_year AS metric_time__extract_year + , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_6.metric_time__extract_month AS metric_time__extract_month + , subq_6.listing AS listing + , subq_6.booking__listing AS booking__listing + , subq_6.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC(subq_4.ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-03-05' AND '2021-01-04' + DATE_TRUNC(subq_8.ds, month) AS metric_time__month + FROM ***************************.mf_time_spine subq_8 + WHERE subq_8.ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY metric_time__month - ) subq_3 + ) subq_7 INNER JOIN ( -- Constrain Time Range to [2019-12-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_1.monthly_ds__month - , subq_1.monthly_ds__quarter - , subq_1.monthly_ds__year - , subq_1.monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month - , subq_1.booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.listing - , subq_1.booking__listing - , subq_1.bookings_monthly + subq_5.monthly_ds__month + , subq_5.monthly_ds__quarter + , subq_5.monthly_ds__year + , subq_5.monthly_ds__extract_year + , subq_5.monthly_ds__extract_quarter + , subq_5.monthly_ds__extract_month + , subq_5.booking__monthly_ds__month + , subq_5.booking__monthly_ds__quarter + , subq_5.booking__monthly_ds__year + , subq_5.booking__monthly_ds__extract_year + , subq_5.booking__monthly_ds__extract_quarter + , subq_5.booking__monthly_ds__extract_month + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.listing + , subq_5.booking__listing + , subq_5.bookings_monthly FROM ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_4.monthly_ds__month + , subq_4.monthly_ds__quarter + , subq_4.monthly_ds__year + , subq_4.monthly_ds__extract_year + , subq_4.monthly_ds__extract_quarter + , subq_4.monthly_ds__extract_month + , subq_4.booking__monthly_ds__month + , subq_4.booking__monthly_ds__quarter + , subq_4.booking__monthly_ds__year + , subq_4.booking__monthly_ds__extract_year + , subq_4.booking__monthly_ds__extract_quarter + , subq_4.booking__monthly_ds__extract_month + , subq_4.monthly_ds__month AS metric_time__month + , subq_4.monthly_ds__quarter AS metric_time__quarter + , subq_4.monthly_ds__year AS metric_time__year + , subq_4.monthly_ds__extract_year AS metric_time__extract_year + , subq_4.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_4.monthly_ds__extract_month AS metric_time__extract_month + , subq_4.listing + , subq_4.booking__listing + , subq_4.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -117,20 +117,20 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' - ) subq_2 + ) subq_4 + ) subq_5 + WHERE subq_5.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' + ) subq_6 ON ( - subq_2.metric_time__month <= subq_3.metric_time__month + subq_6.metric_time__month <= subq_7.metric_time__month ) AND ( - subq_2.metric_time__month > DATE_SUB(CAST(subq_3.metric_time__month AS DATETIME), INTERVAL 3 month) + subq_6.metric_time__month > DATE_SUB(CAST(subq_7.metric_time__month AS DATETIME), INTERVAL 3 month) ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' - ) subq_7 + ) subq_9 + ) subq_10 + WHERE subq_10.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' + ) subq_11 GROUP BY metric_time__month -) subq_8 +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0_optimized.sql index cebaf3f59a..245aa03a19 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.bookings_monthly) AS trailing_3_months_bookings + subq_16.metric_time__month AS metric_time__month + , SUM(subq_15.bookings_monthly) AS trailing_3_months_bookings FROM ( -- Time Spine SELECT DATE_TRUNC(ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_17 WHERE ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY metric_time__month -) subq_12 +) subq_16 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_monthly_source' -- Metric Time Dimension 'monthly_ds' @@ -24,13 +24,13 @@ INNER JOIN ( , bookings_monthly FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 WHERE DATE_TRUNC(ds, month) BETWEEN '2019-12-05' AND '2021-01-04' -) subq_11 +) subq_15 ON ( - subq_11.metric_time__month <= subq_12.metric_time__month + subq_15.metric_time__month <= subq_16.metric_time__month ) AND ( - subq_11.metric_time__month > DATE_SUB(CAST(subq_12.metric_time__month AS DATETIME), INTERVAL 3 month) + subq_15.metric_time__month > DATE_SUB(CAST(subq_16.metric_time__month AS DATETIME), INTERVAL 3 month) ) -WHERE subq_12.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' +WHERE subq_16.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0.sql index 556e45ac8a..ce5bdd3d39 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0.sql @@ -1,83 +1,83 @@ -- Compute Metrics via Expressions SELECT - subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - SUM(subq_2.txn_revenue) AS txn_revenue + SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue',] SELECT - subq_1.txn_revenue + subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_28007.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_28007.created_at, day) AS revenue_instance__ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS revenue_instance__ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS revenue_instance__ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS revenue_instance__ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS revenue_instance__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 -) subq_3 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_28000.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_28000.created_at, day) AS revenue_instance__ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS revenue_instance__ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS revenue_instance__ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS revenue_instance__ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS revenue_instance__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0_optimized.sql index e26a1bdb3d..4a0d5baff3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0_optimized.sql @@ -5,4 +5,4 @@ -- Compute Metrics via Expressions SELECT SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0.sql index 5b266bf166..5e199eb346 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_all_time + subq_12.ds__month + , subq_12.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_28007.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_28007.created_at, day) AS revenue_instance__ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS revenue_instance__ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS revenue_instance__ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS revenue_instance__ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS revenue_instance__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_28000.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_28000.created_at, day) AS revenue_instance__ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS revenue_instance__ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS revenue_instance__ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS revenue_instance__ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS revenue_instance__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY ds__month -) subq_3 +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0_optimized.sql index facf505f90..0bea520ecc 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC(created_at, month) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY ds__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 9f6add1096..8a592ea090 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -1,187 +1,187 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.txn_revenue AS revenue_all_time + subq_19.metric_time__month + , subq_19.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__month + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.txn_revenue + subq_17.metric_time__month + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.txn_revenue + subq_16.metric_time__month + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__day AS metric_time__day - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__month AS metric_time__month + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__day AS metric_time__day + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - DATE_TRUNC(subq_4.ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + DATE_TRUNC(subq_15.ds, month) AS metric_time__month + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY metric_time__month - ) subq_3 + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_28007.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_28007.created_at, day) AS revenue_instance__ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS revenue_instance__ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS revenue_instance__ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS revenue_instance__ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS revenue_instance__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_28000.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_28000.created_at, day) AS revenue_instance__ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS revenue_instance__ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS revenue_instance__ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS revenue_instance__ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS revenue_instance__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' + ) subq_13 ON - (subq_2.metric_time__month <= subq_3.metric_time__month) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_7 + (subq_13.metric_time__month <= subq_14.metric_time__month) + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_18 GROUP BY metric_time__month -) subq_8 +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 588064f322..380b81d94a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.txn_revenue) AS revenue_all_time + subq_23.metric_time__month AS metric_time__month + , SUM(subq_22.txn_revenue) AS revenue_all_time FROM ( -- Time Spine SELECT DATE_TRUNC(ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY metric_time__month -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -22,11 +22,11 @@ INNER JOIN ( SELECT DATE_TRUNC(created_at, month) AS metric_time__month , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC(created_at, day) BETWEEN '2000-01-01' AND '2020-01-01' -) subq_11 +) subq_22 ON - (subq_11.metric_time__month <= subq_12.metric_time__month) -WHERE subq_12.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + (subq_22.metric_time__month <= subq_23.metric_time__month) +WHERE subq_23.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0.sql index fc1a7fcd07..58aad0e832 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0.sql @@ -1,140 +1,140 @@ -- Compute Metrics via Expressions SELECT - subq_6.revenue_instance__ds__day - , subq_6.txn_revenue AS trailing_2_months_revenue + subq_15.revenue_instance__ds__day + , subq_15.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_5.revenue_instance__ds__day - , SUM(subq_5.txn_revenue) AS txn_revenue + subq_14.revenue_instance__ds__day + , SUM(subq_14.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'revenue_instance__ds__day'] SELECT - subq_4.revenue_instance__ds__day - , subq_4.txn_revenue + subq_13.revenue_instance__ds__day + , subq_13.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_1.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.user AS user - , subq_1.revenue_instance__user AS revenue_instance__user - , subq_1.txn_revenue AS txn_revenue + subq_11.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_10.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_10.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_10.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_10.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_10.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_10.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_10.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_10.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_10.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.user AS user + , subq_10.revenue_instance__user AS revenue_instance__user + , subq_10.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS revenue_instance__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_28007.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_28007.created_at, day) AS revenue_instance__ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS revenue_instance__ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS revenue_instance__ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS revenue_instance__ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS revenue_instance__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_28000.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_28000.created_at, day) AS revenue_instance__ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS revenue_instance__ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS revenue_instance__ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS revenue_instance__ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS revenue_instance__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 ON ( - subq_1.revenue_instance__ds__day <= subq_2.revenue_instance__ds__day + subq_10.revenue_instance__ds__day <= subq_11.revenue_instance__ds__day ) AND ( - subq_1.revenue_instance__ds__day > DATE_SUB(CAST(subq_2.revenue_instance__ds__day AS DATETIME), INTERVAL 2 month) + subq_10.revenue_instance__ds__day > DATE_SUB(CAST(subq_11.revenue_instance__ds__day AS DATETIME), INTERVAL 2 month) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY revenue_instance__ds__day -) subq_6 +) subq_15 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql index 1f114b5424..6f50935572 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql @@ -3,16 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ds AS revenue_instance__ds__day - , SUM(revenue_src_28007.revenue) AS trailing_2_months_revenue -FROM ***************************.mf_time_spine subq_10 + subq_19.ds AS revenue_instance__ds__day + , SUM(revenue_src_28000.revenue) AS trailing_2_months_revenue +FROM ***************************.mf_time_spine subq_19 INNER JOIN - ***************************.fct_revenue revenue_src_28007 + ***************************.fct_revenue revenue_src_28000 ON ( - DATE_TRUNC(revenue_src_28007.created_at, day) <= subq_10.ds + DATE_TRUNC(revenue_src_28000.created_at, day) <= subq_19.ds ) AND ( - DATE_TRUNC(revenue_src_28007.created_at, day) > DATE_SUB(CAST(subq_10.ds AS DATETIME), INTERVAL 2 month) + DATE_TRUNC(revenue_src_28000.created_at, day) > DATE_SUB(CAST(subq_19.ds AS DATETIME), INTERVAL 2 month) ) GROUP BY revenue_instance__ds__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index 8c3004f444..70bcdf123e 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -1,334 +1,334 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.bookers AS every_two_days_bookers + subq_16.metric_time__day + , subq_16.bookers AS every_two_days_bookers FROM ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , COUNT(DISTINCT subq_6.bookers) AS bookers + subq_15.metric_time__day + , COUNT(DISTINCT subq_15.bookers) AS bookers FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.bookers + subq_14.metric_time__day + , subq_14.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 2 day) + subq_10.metric_time__day > DATE_SUB(CAST(subq_11.metric_time__day AS DATETIME), INTERVAL 2 day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' - ) subq_6 + ) subq_15 GROUP BY metric_time__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index 48c38d8b33..cd07357409 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -8,18 +8,18 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_11.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_20 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC(bookings_source_src_28001.ds, day) <= subq_11.ds + DATE_TRUNC(bookings_source_src_28000.ds, day) <= subq_20.ds ) AND ( - DATE_TRUNC(bookings_source_src_28001.ds, day) > DATE_SUB(CAST(subq_11.ds AS DATETIME), INTERVAL 2 day) + DATE_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_20.ds AS DATETIME), INTERVAL 2 day) ) -) subq_13 +) subq_22 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql index a59b1c6bd7..34d08d65d9 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql @@ -1,189 +1,189 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.txn_revenue AS trailing_2_months_revenue + subq_19.metric_time__day + , subq_19.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__day + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__day - , subq_6.txn_revenue + subq_17.metric_time__day + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.txn_revenue + subq_16.metric_time__day + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__day AS metric_time__day - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__month AS metric_time__month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__month AS metric_time__month + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_3 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC(revenue_src_28007.created_at, day) AS ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC(revenue_src_28007.created_at, day) AS revenue_instance__ds__day - , DATE_TRUNC(revenue_src_28007.created_at, isoweek) AS revenue_instance__ds__week - , DATE_TRUNC(revenue_src_28007.created_at, month) AS revenue_instance__ds__month - , DATE_TRUNC(revenue_src_28007.created_at, quarter) AS revenue_instance__ds__quarter - , DATE_TRUNC(revenue_src_28007.created_at, year) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , IF(EXTRACT(dayofweek FROM revenue_src_28007.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28007.created_at) - 1) AS revenue_instance__ds__extract_dow - , EXTRACT(dayofyear FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC(revenue_src_28000.created_at, day) AS ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC(revenue_src_28000.created_at, day) AS revenue_instance__ds__day + , DATE_TRUNC(revenue_src_28000.created_at, isoweek) AS revenue_instance__ds__week + , DATE_TRUNC(revenue_src_28000.created_at, month) AS revenue_instance__ds__month + , DATE_TRUNC(revenue_src_28000.created_at, quarter) AS revenue_instance__ds__quarter + , DATE_TRUNC(revenue_src_28000.created_at, year) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , IF(EXTRACT(dayofweek FROM revenue_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM revenue_src_28000.created_at) - 1) AS revenue_instance__ds__extract_dow + , EXTRACT(dayofyear FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' + ) subq_13 ON ( - subq_2.metric_time__day <= subq_3.metric_time__day + subq_13.metric_time__day <= subq_14.metric_time__day ) AND ( - subq_2.metric_time__day > DATE_SUB(CAST(subq_3.metric_time__day AS DATETIME), INTERVAL 2 month) + subq_13.metric_time__day > DATE_SUB(CAST(subq_14.metric_time__day AS DATETIME), INTERVAL 2 month) ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_7 + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_18 GROUP BY metric_time__day -) subq_8 +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 0d30972ced..1e055c92db 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -4,15 +4,15 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day AS metric_time__day - , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue + subq_23.metric_time__day AS metric_time__day + , SUM(subq_22.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -20,15 +20,15 @@ INNER JOIN ( SELECT DATE_TRUNC(created_at, day) AS metric_time__day , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC(created_at, day) BETWEEN '2019-11-01' AND '2020-01-01' -) subq_11 +) subq_22 ON ( - subq_11.metric_time__day <= subq_12.metric_time__day + subq_22.metric_time__day <= subq_23.metric_time__day ) AND ( - subq_11.metric_time__day > DATE_SUB(CAST(subq_12.metric_time__day AS DATETIME), INTERVAL 2 month) + subq_22.metric_time__day > DATE_SUB(CAST(subq_23.metric_time__day AS DATETIME), INTERVAL 2 month) ) -WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_23.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0.sql index e96f97bd79..0814ce4d52 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.ds__day + , subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__day + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.txn_revenue + subq_10.ds__day + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__day -) subq_3 + subq_11.ds__day +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0_optimized.sql index 749250c230..76e8f3252a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('day', created_at) AS ds__day , SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('day', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0.sql index 507f2d3739..5061775482 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_mtd + subq_12.ds__month + , subq_12.txn_revenue AS revenue_mtd FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__month -) subq_3 + subq_11.ds__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0_optimized.sql index 6a6dbce8b9..e057084866 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_mtd -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0.sql index 5bc9116fc1..cc865b5b84 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0.sql @@ -1,103 +1,103 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.bookings_monthly AS trailing_3_months_bookings + subq_12.metric_time__month + , subq_12.bookings_monthly AS trailing_3_months_bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.bookings_monthly) AS bookings_monthly + subq_11.metric_time__month + , SUM(subq_11.bookings_monthly) AS bookings_monthly FROM ( -- Constrain Time Range to [2020-03-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly + subq_10.metric_time__month + , subq_10.bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.bookings_monthly + subq_9.metric_time__month + , subq_9.bookings_monthly FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.monthly_ds__month AS monthly_ds__month - , subq_2.monthly_ds__quarter AS monthly_ds__quarter - , subq_2.monthly_ds__year AS monthly_ds__year - , subq_2.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_2.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_2.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_2.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_2.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_2.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_2.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_2.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_2.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.listing AS listing - , subq_2.booking__listing AS booking__listing - , subq_2.bookings_monthly AS bookings_monthly + subq_7.metric_time__month AS metric_time__month + , subq_6.monthly_ds__month AS monthly_ds__month + , subq_6.monthly_ds__quarter AS monthly_ds__quarter + , subq_6.monthly_ds__year AS monthly_ds__year + , subq_6.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_6.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_6.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_6.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_6.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_6.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_6.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_6.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_6.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_6.metric_time__quarter AS metric_time__quarter + , subq_6.metric_time__year AS metric_time__year + , subq_6.metric_time__extract_year AS metric_time__extract_year + , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_6.metric_time__extract_month AS metric_time__extract_month + , subq_6.listing AS listing + , subq_6.booking__listing AS booking__listing + , subq_6.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_4.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-03-05' AND '2021-01-04' + DATE_TRUNC('month', subq_8.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_8 + WHERE subq_8.ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - DATE_TRUNC('month', subq_4.ds) - ) subq_3 + DATE_TRUNC('month', subq_8.ds) + ) subq_7 INNER JOIN ( -- Constrain Time Range to [2019-12-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_1.monthly_ds__month - , subq_1.monthly_ds__quarter - , subq_1.monthly_ds__year - , subq_1.monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month - , subq_1.booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.listing - , subq_1.booking__listing - , subq_1.bookings_monthly + subq_5.monthly_ds__month + , subq_5.monthly_ds__quarter + , subq_5.monthly_ds__year + , subq_5.monthly_ds__extract_year + , subq_5.monthly_ds__extract_quarter + , subq_5.monthly_ds__extract_month + , subq_5.booking__monthly_ds__month + , subq_5.booking__monthly_ds__quarter + , subq_5.booking__monthly_ds__year + , subq_5.booking__monthly_ds__extract_year + , subq_5.booking__monthly_ds__extract_quarter + , subq_5.booking__monthly_ds__extract_month + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.listing + , subq_5.booking__listing + , subq_5.bookings_monthly FROM ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_4.monthly_ds__month + , subq_4.monthly_ds__quarter + , subq_4.monthly_ds__year + , subq_4.monthly_ds__extract_year + , subq_4.monthly_ds__extract_quarter + , subq_4.monthly_ds__extract_month + , subq_4.booking__monthly_ds__month + , subq_4.booking__monthly_ds__quarter + , subq_4.booking__monthly_ds__year + , subq_4.booking__monthly_ds__extract_year + , subq_4.booking__monthly_ds__extract_quarter + , subq_4.booking__monthly_ds__extract_month + , subq_4.monthly_ds__month AS metric_time__month + , subq_4.monthly_ds__quarter AS metric_time__quarter + , subq_4.monthly_ds__year AS metric_time__year + , subq_4.monthly_ds__extract_year AS metric_time__extract_year + , subq_4.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_4.monthly_ds__extract_month AS metric_time__extract_month + , subq_4.listing + , subq_4.booking__listing + , subq_4.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -117,20 +117,20 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' - ) subq_2 + ) subq_4 + ) subq_5 + WHERE subq_5.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' + ) subq_6 ON ( - subq_2.metric_time__month <= subq_3.metric_time__month + subq_6.metric_time__month <= subq_7.metric_time__month ) AND ( - subq_2.metric_time__month > DATEADD(month, -3, subq_3.metric_time__month) + subq_6.metric_time__month > DATEADD(month, -3, subq_7.metric_time__month) ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' - ) subq_7 + ) subq_9 + ) subq_10 + WHERE subq_10.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' + ) subq_11 GROUP BY - subq_7.metric_time__month -) subq_8 + subq_11.metric_time__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0_optimized.sql index 4611f8316c..c9b1da3166 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.bookings_monthly) AS trailing_3_months_bookings + subq_16.metric_time__month AS metric_time__month + , SUM(subq_15.bookings_monthly) AS trailing_3_months_bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_17 WHERE ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY DATE_TRUNC('month', ds) -) subq_12 +) subq_16 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_monthly_source' -- Metric Time Dimension 'monthly_ds' @@ -24,13 +24,13 @@ INNER JOIN ( , bookings_monthly FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 WHERE DATE_TRUNC('month', ds) BETWEEN '2019-12-05' AND '2021-01-04' -) subq_11 +) subq_15 ON ( - subq_11.metric_time__month <= subq_12.metric_time__month + subq_15.metric_time__month <= subq_16.metric_time__month ) AND ( - subq_11.metric_time__month > DATEADD(month, -3, subq_12.metric_time__month) + subq_15.metric_time__month > DATEADD(month, -3, subq_16.metric_time__month) ) -WHERE subq_12.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' +WHERE subq_16.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - subq_12.metric_time__month + subq_16.metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0.sql index 56e72d2eb4..58f997122b 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0.sql @@ -1,83 +1,83 @@ -- Compute Metrics via Expressions SELECT - subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - SUM(subq_2.txn_revenue) AS txn_revenue + SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue',] SELECT - subq_1.txn_revenue + subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 -) subq_3 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0_optimized.sql index e26a1bdb3d..4a0d5baff3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0_optimized.sql @@ -5,4 +5,4 @@ -- Compute Metrics via Expressions SELECT SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0.sql index 3b1f31cc45..3de41e1670 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_all_time + subq_12.ds__month + , subq_12.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__month -) subq_3 + subq_11.ds__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0_optimized.sql index a7ca78d4e5..05e48cdae3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 3b1941bbb6..1f21fb1984 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -1,187 +1,187 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.txn_revenue AS revenue_all_time + subq_19.metric_time__month + , subq_19.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__month + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.txn_revenue + subq_17.metric_time__month + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.txn_revenue + subq_16.metric_time__month + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__day AS metric_time__day - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__month AS metric_time__month + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__day AS metric_time__day + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_4.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + DATE_TRUNC('month', subq_15.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - DATE_TRUNC('month', subq_4.ds) - ) subq_3 + DATE_TRUNC('month', subq_15.ds) + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' + ) subq_13 ON - (subq_2.metric_time__month <= subq_3.metric_time__month) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_7 + (subq_13.metric_time__month <= subq_14.metric_time__month) + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_18 GROUP BY - subq_7.metric_time__month -) subq_8 + subq_18.metric_time__month +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index a4e5bf994b..0267f01b4a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.txn_revenue) AS revenue_all_time + subq_23.metric_time__month AS metric_time__month + , SUM(subq_22.txn_revenue) AS revenue_all_time FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', ds) -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -22,11 +22,11 @@ INNER JOIN ( SELECT DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' -) subq_11 +) subq_22 ON - (subq_11.metric_time__month <= subq_12.metric_time__month) -WHERE subq_12.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + (subq_22.metric_time__month <= subq_23.metric_time__month) +WHERE subq_23.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_12.metric_time__month + subq_23.metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0.sql index de0af3a855..cf0aaa51ea 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0.sql @@ -1,140 +1,140 @@ -- Compute Metrics via Expressions SELECT - subq_6.revenue_instance__ds__day - , subq_6.txn_revenue AS trailing_2_months_revenue + subq_15.revenue_instance__ds__day + , subq_15.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_5.revenue_instance__ds__day - , SUM(subq_5.txn_revenue) AS txn_revenue + subq_14.revenue_instance__ds__day + , SUM(subq_14.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'revenue_instance__ds__day'] SELECT - subq_4.revenue_instance__ds__day - , subq_4.txn_revenue + subq_13.revenue_instance__ds__day + , subq_13.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_1.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.user AS user - , subq_1.revenue_instance__user AS revenue_instance__user - , subq_1.txn_revenue AS txn_revenue + subq_11.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_10.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_10.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_10.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_10.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_10.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_10.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_10.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_10.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_10.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.user AS user + , subq_10.revenue_instance__user AS revenue_instance__user + , subq_10.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS revenue_instance__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 ON ( - subq_1.revenue_instance__ds__day <= subq_2.revenue_instance__ds__day + subq_10.revenue_instance__ds__day <= subq_11.revenue_instance__ds__day ) AND ( - subq_1.revenue_instance__ds__day > DATEADD(month, -2, subq_2.revenue_instance__ds__day) + subq_10.revenue_instance__ds__day > DATEADD(month, -2, subq_11.revenue_instance__ds__day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY - subq_5.revenue_instance__ds__day -) subq_6 + subq_14.revenue_instance__ds__day +) subq_15 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql index 501e54f5dd..9769ddd7de 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql @@ -3,16 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ds AS revenue_instance__ds__day - , SUM(revenue_src_28007.revenue) AS trailing_2_months_revenue -FROM ***************************.mf_time_spine subq_10 + subq_19.ds AS revenue_instance__ds__day + , SUM(revenue_src_28000.revenue) AS trailing_2_months_revenue +FROM ***************************.mf_time_spine subq_19 INNER JOIN - ***************************.fct_revenue revenue_src_28007 + ***************************.fct_revenue revenue_src_28000 ON ( - DATE_TRUNC('day', revenue_src_28007.created_at) <= subq_10.ds + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_19.ds ) AND ( - DATE_TRUNC('day', revenue_src_28007.created_at) > DATEADD(month, -2, subq_10.ds) + DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_19.ds) ) GROUP BY - subq_10.ds + subq_19.ds diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index 49fd732c02..b97b754096 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -1,334 +1,334 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.bookers AS every_two_days_bookers + subq_16.metric_time__day + , subq_16.bookers AS every_two_days_bookers FROM ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , COUNT(DISTINCT subq_6.bookers) AS bookers + subq_15.metric_time__day + , COUNT(DISTINCT subq_15.bookers) AS bookers FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.bookers + subq_14.metric_time__day + , subq_14.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -2, subq_11.metric_time__day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' - ) subq_6 + ) subq_15 GROUP BY - subq_6.metric_time__day -) subq_7 + subq_15.metric_time__day +) subq_16 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index aa43d7d7d6..ab8b4812ed 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -8,18 +8,18 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_11.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_20 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_11.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_20.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATEADD(day, -2, subq_11.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_20.ds) ) -) subq_13 +) subq_22 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql index f3b2cee287..3cf90d835b 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql @@ -1,189 +1,189 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.txn_revenue AS trailing_2_months_revenue + subq_19.metric_time__day + , subq_19.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__day + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__day - , subq_6.txn_revenue + subq_17.metric_time__day + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.txn_revenue + subq_16.metric_time__day + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__day AS metric_time__day - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__month AS metric_time__month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__month AS metric_time__month + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_3 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' + ) subq_13 ON ( - subq_2.metric_time__day <= subq_3.metric_time__day + subq_13.metric_time__day <= subq_14.metric_time__day ) AND ( - subq_2.metric_time__day > DATEADD(month, -2, subq_3.metric_time__day) + subq_13.metric_time__day > DATEADD(month, -2, subq_14.metric_time__day) ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_7 + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_18 GROUP BY - subq_7.metric_time__day -) subq_8 + subq_18.metric_time__day +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 06ea3f5a91..bb3417f1ce 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -4,15 +4,15 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day AS metric_time__day - , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue + subq_23.metric_time__day AS metric_time__day + , SUM(subq_22.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -20,15 +20,15 @@ INNER JOIN ( SELECT DATE_TRUNC('day', created_at) AS metric_time__day , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' -) subq_11 +) subq_22 ON ( - subq_11.metric_time__day <= subq_12.metric_time__day + subq_22.metric_time__day <= subq_23.metric_time__day ) AND ( - subq_11.metric_time__day > DATEADD(month, -2, subq_12.metric_time__day) + subq_22.metric_time__day > DATEADD(month, -2, subq_23.metric_time__day) ) -WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_23.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_12.metric_time__day + subq_23.metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql index a19c35420a..7b75ca51c5 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.ds__day + , subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__day + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.txn_revenue + subq_10.ds__day + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__day -) subq_3 + subq_11.ds__day +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0_optimized.sql index 749250c230..76e8f3252a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('day', created_at) AS ds__day , SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('day', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0.sql index af8623a007..a3900c0466 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_mtd + subq_12.ds__month + , subq_12.txn_revenue AS revenue_mtd FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__month -) subq_3 + subq_11.ds__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0_optimized.sql index 6a6dbce8b9..e057084866 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_mtd -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_month__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_month__plan0.sql index 238774265f..0e91f53041 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_month__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_month__plan0.sql @@ -1,103 +1,103 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.bookings_monthly AS trailing_3_months_bookings + subq_12.metric_time__month + , subq_12.bookings_monthly AS trailing_3_months_bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.bookings_monthly) AS bookings_monthly + subq_11.metric_time__month + , SUM(subq_11.bookings_monthly) AS bookings_monthly FROM ( -- Constrain Time Range to [2020-03-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly + subq_10.metric_time__month + , subq_10.bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.bookings_monthly + subq_9.metric_time__month + , subq_9.bookings_monthly FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.monthly_ds__month AS monthly_ds__month - , subq_2.monthly_ds__quarter AS monthly_ds__quarter - , subq_2.monthly_ds__year AS monthly_ds__year - , subq_2.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_2.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_2.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_2.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_2.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_2.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_2.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_2.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_2.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.listing AS listing - , subq_2.booking__listing AS booking__listing - , subq_2.bookings_monthly AS bookings_monthly + subq_7.metric_time__month AS metric_time__month + , subq_6.monthly_ds__month AS monthly_ds__month + , subq_6.monthly_ds__quarter AS monthly_ds__quarter + , subq_6.monthly_ds__year AS monthly_ds__year + , subq_6.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_6.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_6.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_6.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_6.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_6.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_6.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_6.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_6.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_6.metric_time__quarter AS metric_time__quarter + , subq_6.metric_time__year AS metric_time__year + , subq_6.metric_time__extract_year AS metric_time__extract_year + , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_6.metric_time__extract_month AS metric_time__extract_month + , subq_6.listing AS listing + , subq_6.booking__listing AS booking__listing + , subq_6.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_4.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-03-05' AND '2021-01-04' + DATE_TRUNC('month', subq_8.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_8 + WHERE subq_8.ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - DATE_TRUNC('month', subq_4.ds) - ) subq_3 + DATE_TRUNC('month', subq_8.ds) + ) subq_7 INNER JOIN ( -- Constrain Time Range to [2019-12-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_1.monthly_ds__month - , subq_1.monthly_ds__quarter - , subq_1.monthly_ds__year - , subq_1.monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month - , subq_1.booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.listing - , subq_1.booking__listing - , subq_1.bookings_monthly + subq_5.monthly_ds__month + , subq_5.monthly_ds__quarter + , subq_5.monthly_ds__year + , subq_5.monthly_ds__extract_year + , subq_5.monthly_ds__extract_quarter + , subq_5.monthly_ds__extract_month + , subq_5.booking__monthly_ds__month + , subq_5.booking__monthly_ds__quarter + , subq_5.booking__monthly_ds__year + , subq_5.booking__monthly_ds__extract_year + , subq_5.booking__monthly_ds__extract_quarter + , subq_5.booking__monthly_ds__extract_month + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.listing + , subq_5.booking__listing + , subq_5.bookings_monthly FROM ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_4.monthly_ds__month + , subq_4.monthly_ds__quarter + , subq_4.monthly_ds__year + , subq_4.monthly_ds__extract_year + , subq_4.monthly_ds__extract_quarter + , subq_4.monthly_ds__extract_month + , subq_4.booking__monthly_ds__month + , subq_4.booking__monthly_ds__quarter + , subq_4.booking__monthly_ds__year + , subq_4.booking__monthly_ds__extract_year + , subq_4.booking__monthly_ds__extract_quarter + , subq_4.booking__monthly_ds__extract_month + , subq_4.monthly_ds__month AS metric_time__month + , subq_4.monthly_ds__quarter AS metric_time__quarter + , subq_4.monthly_ds__year AS metric_time__year + , subq_4.monthly_ds__extract_year AS metric_time__extract_year + , subq_4.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_4.monthly_ds__extract_month AS metric_time__extract_month + , subq_4.listing + , subq_4.booking__listing + , subq_4.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -117,20 +117,20 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' - ) subq_2 + ) subq_4 + ) subq_5 + WHERE subq_5.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' + ) subq_6 ON ( - subq_2.metric_time__month <= subq_3.metric_time__month + subq_6.metric_time__month <= subq_7.metric_time__month ) AND ( - subq_2.metric_time__month > subq_3.metric_time__month - INTERVAL 3 month + subq_6.metric_time__month > subq_7.metric_time__month - INTERVAL 3 month ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' - ) subq_7 + ) subq_9 + ) subq_10 + WHERE subq_10.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' + ) subq_11 GROUP BY - subq_7.metric_time__month -) subq_8 + subq_11.metric_time__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_month__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_month__plan0_optimized.sql index df00087c33..6a57a72ab0 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_month__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.bookings_monthly) AS trailing_3_months_bookings + subq_16.metric_time__month AS metric_time__month + , SUM(subq_15.bookings_monthly) AS trailing_3_months_bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_17 WHERE ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY DATE_TRUNC('month', ds) -) subq_12 +) subq_16 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_monthly_source' -- Metric Time Dimension 'monthly_ds' @@ -24,13 +24,13 @@ INNER JOIN ( , bookings_monthly FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 WHERE DATE_TRUNC('month', ds) BETWEEN '2019-12-05' AND '2021-01-04' -) subq_11 +) subq_15 ON ( - subq_11.metric_time__month <= subq_12.metric_time__month + subq_15.metric_time__month <= subq_16.metric_time__month ) AND ( - subq_11.metric_time__month > subq_12.metric_time__month - INTERVAL 3 month + subq_15.metric_time__month > subq_16.metric_time__month - INTERVAL 3 month ) -WHERE subq_12.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' +WHERE subq_16.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - subq_12.metric_time__month + subq_16.metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0.sql index 740a8baf27..089925950f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0.sql @@ -1,83 +1,83 @@ -- Compute Metrics via Expressions SELECT - subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - SUM(subq_2.txn_revenue) AS txn_revenue + SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue',] SELECT - subq_1.txn_revenue + subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 -) subq_3 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0_optimized.sql index e26a1bdb3d..4a0d5baff3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0_optimized.sql @@ -5,4 +5,4 @@ -- Compute Metrics via Expressions SELECT SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0.sql index c134310b8b..8aaa691cd5 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_all_time + subq_12.ds__month + , subq_12.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__month -) subq_3 + subq_11.ds__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0_optimized.sql index a7ca78d4e5..05e48cdae3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 61b9bcc9ac..f781a5a6f4 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -1,187 +1,187 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.txn_revenue AS revenue_all_time + subq_19.metric_time__month + , subq_19.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__month + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.txn_revenue + subq_17.metric_time__month + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.txn_revenue + subq_16.metric_time__month + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__day AS metric_time__day - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__month AS metric_time__month + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__day AS metric_time__day + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_4.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + DATE_TRUNC('month', subq_15.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - DATE_TRUNC('month', subq_4.ds) - ) subq_3 + DATE_TRUNC('month', subq_15.ds) + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' + ) subq_13 ON - (subq_2.metric_time__month <= subq_3.metric_time__month) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_7 + (subq_13.metric_time__month <= subq_14.metric_time__month) + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_18 GROUP BY - subq_7.metric_time__month -) subq_8 + subq_18.metric_time__month +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index a4e5bf994b..0267f01b4a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.txn_revenue) AS revenue_all_time + subq_23.metric_time__month AS metric_time__month + , SUM(subq_22.txn_revenue) AS revenue_all_time FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', ds) -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -22,11 +22,11 @@ INNER JOIN ( SELECT DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' -) subq_11 +) subq_22 ON - (subq_11.metric_time__month <= subq_12.metric_time__month) -WHERE subq_12.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + (subq_22.metric_time__month <= subq_23.metric_time__month) +WHERE subq_23.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_12.metric_time__month + subq_23.metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_agg_time_dimension__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_agg_time_dimension__plan0.sql index 68477c9e75..f5c3b5d57c 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_agg_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_agg_time_dimension__plan0.sql @@ -1,140 +1,140 @@ -- Compute Metrics via Expressions SELECT - subq_6.revenue_instance__ds__day - , subq_6.txn_revenue AS trailing_2_months_revenue + subq_15.revenue_instance__ds__day + , subq_15.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_5.revenue_instance__ds__day - , SUM(subq_5.txn_revenue) AS txn_revenue + subq_14.revenue_instance__ds__day + , SUM(subq_14.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'revenue_instance__ds__day'] SELECT - subq_4.revenue_instance__ds__day - , subq_4.txn_revenue + subq_13.revenue_instance__ds__day + , subq_13.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_1.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.user AS user - , subq_1.revenue_instance__user AS revenue_instance__user - , subq_1.txn_revenue AS txn_revenue + subq_11.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_10.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_10.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_10.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_10.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_10.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_10.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_10.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_10.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_10.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.user AS user + , subq_10.revenue_instance__user AS revenue_instance__user + , subq_10.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS revenue_instance__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 ON ( - subq_1.revenue_instance__ds__day <= subq_2.revenue_instance__ds__day + subq_10.revenue_instance__ds__day <= subq_11.revenue_instance__ds__day ) AND ( - subq_1.revenue_instance__ds__day > subq_2.revenue_instance__ds__day - INTERVAL 2 month + subq_10.revenue_instance__ds__day > subq_11.revenue_instance__ds__day - INTERVAL 2 month ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY - subq_5.revenue_instance__ds__day -) subq_6 + subq_14.revenue_instance__ds__day +) subq_15 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql index 2cfdd396a1..4bca1960c0 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql @@ -3,16 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ds AS revenue_instance__ds__day - , SUM(revenue_src_28007.revenue) AS trailing_2_months_revenue -FROM ***************************.mf_time_spine subq_10 + subq_19.ds AS revenue_instance__ds__day + , SUM(revenue_src_28000.revenue) AS trailing_2_months_revenue +FROM ***************************.mf_time_spine subq_19 INNER JOIN - ***************************.fct_revenue revenue_src_28007 + ***************************.fct_revenue revenue_src_28000 ON ( - DATE_TRUNC('day', revenue_src_28007.created_at) <= subq_10.ds + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_19.ds ) AND ( - DATE_TRUNC('day', revenue_src_28007.created_at) > subq_10.ds - INTERVAL 2 month + DATE_TRUNC('day', revenue_src_28000.created_at) > subq_19.ds - INTERVAL 2 month ) GROUP BY - subq_10.ds + subq_19.ds diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index 632c06ae57..04c746e295 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -1,334 +1,334 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.bookers AS every_two_days_bookers + subq_16.metric_time__day + , subq_16.bookers AS every_two_days_bookers FROM ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , COUNT(DISTINCT subq_6.bookers) AS bookers + subq_15.metric_time__day + , COUNT(DISTINCT subq_15.bookers) AS bookers FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.bookers + subq_14.metric_time__day + , subq_14.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > subq_2.metric_time__day - INTERVAL 2 day + subq_10.metric_time__day > subq_11.metric_time__day - INTERVAL 2 day ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' - ) subq_6 + ) subq_15 GROUP BY - subq_6.metric_time__day -) subq_7 + subq_15.metric_time__day +) subq_16 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index 3f6c0bd9d5..100da0421a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -8,18 +8,18 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_11.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_20 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_11.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_20.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > subq_11.ds - INTERVAL 2 day + DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_20.ds - INTERVAL 2 day ) -) subq_13 +) subq_22 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql index 34b9e71355..f48ab7491e 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql @@ -1,189 +1,189 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.txn_revenue AS trailing_2_months_revenue + subq_19.metric_time__day + , subq_19.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__day + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__day - , subq_6.txn_revenue + subq_17.metric_time__day + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.txn_revenue + subq_16.metric_time__day + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__day AS metric_time__day - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__month AS metric_time__month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__month AS metric_time__month + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_3 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' + ) subq_13 ON ( - subq_2.metric_time__day <= subq_3.metric_time__day + subq_13.metric_time__day <= subq_14.metric_time__day ) AND ( - subq_2.metric_time__day > subq_3.metric_time__day - INTERVAL 2 month + subq_13.metric_time__day > subq_14.metric_time__day - INTERVAL 2 month ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_7 + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_18 GROUP BY - subq_7.metric_time__day -) subq_8 + subq_18.metric_time__day +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 1063445e46..745a4be4aa 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -4,15 +4,15 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day AS metric_time__day - , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue + subq_23.metric_time__day AS metric_time__day + , SUM(subq_22.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -20,15 +20,15 @@ INNER JOIN ( SELECT DATE_TRUNC('day', created_at) AS metric_time__day , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' -) subq_11 +) subq_22 ON ( - subq_11.metric_time__day <= subq_12.metric_time__day + subq_22.metric_time__day <= subq_23.metric_time__day ) AND ( - subq_11.metric_time__day > subq_12.metric_time__day - INTERVAL 2 month + subq_22.metric_time__day > subq_23.metric_time__day - INTERVAL 2 month ) -WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_23.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_12.metric_time__day + subq_23.metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0.sql index a19c35420a..7b75ca51c5 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.ds__day + , subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__day + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.txn_revenue + subq_10.ds__day + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__day -) subq_3 + subq_11.ds__day +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0_optimized.sql index 749250c230..76e8f3252a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('day', created_at) AS ds__day , SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('day', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0.sql index af8623a007..a3900c0466 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_mtd + subq_12.ds__month + , subq_12.txn_revenue AS revenue_mtd FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__month -) subq_3 + subq_11.ds__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0_optimized.sql index 6a6dbce8b9..e057084866 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_mtd -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0.sql index 8c30047781..e3f5faf43c 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0.sql @@ -1,103 +1,103 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.bookings_monthly AS trailing_3_months_bookings + subq_12.metric_time__month + , subq_12.bookings_monthly AS trailing_3_months_bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.bookings_monthly) AS bookings_monthly + subq_11.metric_time__month + , SUM(subq_11.bookings_monthly) AS bookings_monthly FROM ( -- Constrain Time Range to [2020-03-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly + subq_10.metric_time__month + , subq_10.bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.bookings_monthly + subq_9.metric_time__month + , subq_9.bookings_monthly FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.monthly_ds__month AS monthly_ds__month - , subq_2.monthly_ds__quarter AS monthly_ds__quarter - , subq_2.monthly_ds__year AS monthly_ds__year - , subq_2.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_2.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_2.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_2.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_2.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_2.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_2.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_2.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_2.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.listing AS listing - , subq_2.booking__listing AS booking__listing - , subq_2.bookings_monthly AS bookings_monthly + subq_7.metric_time__month AS metric_time__month + , subq_6.monthly_ds__month AS monthly_ds__month + , subq_6.monthly_ds__quarter AS monthly_ds__quarter + , subq_6.monthly_ds__year AS monthly_ds__year + , subq_6.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_6.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_6.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_6.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_6.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_6.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_6.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_6.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_6.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_6.metric_time__quarter AS metric_time__quarter + , subq_6.metric_time__year AS metric_time__year + , subq_6.metric_time__extract_year AS metric_time__extract_year + , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_6.metric_time__extract_month AS metric_time__extract_month + , subq_6.listing AS listing + , subq_6.booking__listing AS booking__listing + , subq_6.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_4.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-03-05' AND '2021-01-04' + DATE_TRUNC('month', subq_8.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_8 + WHERE subq_8.ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - DATE_TRUNC('month', subq_4.ds) - ) subq_3 + DATE_TRUNC('month', subq_8.ds) + ) subq_7 INNER JOIN ( -- Constrain Time Range to [2019-12-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_1.monthly_ds__month - , subq_1.monthly_ds__quarter - , subq_1.monthly_ds__year - , subq_1.monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month - , subq_1.booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.listing - , subq_1.booking__listing - , subq_1.bookings_monthly + subq_5.monthly_ds__month + , subq_5.monthly_ds__quarter + , subq_5.monthly_ds__year + , subq_5.monthly_ds__extract_year + , subq_5.monthly_ds__extract_quarter + , subq_5.monthly_ds__extract_month + , subq_5.booking__monthly_ds__month + , subq_5.booking__monthly_ds__quarter + , subq_5.booking__monthly_ds__year + , subq_5.booking__monthly_ds__extract_year + , subq_5.booking__monthly_ds__extract_quarter + , subq_5.booking__monthly_ds__extract_month + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.listing + , subq_5.booking__listing + , subq_5.bookings_monthly FROM ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_4.monthly_ds__month + , subq_4.monthly_ds__quarter + , subq_4.monthly_ds__year + , subq_4.monthly_ds__extract_year + , subq_4.monthly_ds__extract_quarter + , subq_4.monthly_ds__extract_month + , subq_4.booking__monthly_ds__month + , subq_4.booking__monthly_ds__quarter + , subq_4.booking__monthly_ds__year + , subq_4.booking__monthly_ds__extract_year + , subq_4.booking__monthly_ds__extract_quarter + , subq_4.booking__monthly_ds__extract_month + , subq_4.monthly_ds__month AS metric_time__month + , subq_4.monthly_ds__quarter AS metric_time__quarter + , subq_4.monthly_ds__year AS metric_time__year + , subq_4.monthly_ds__extract_year AS metric_time__extract_year + , subq_4.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_4.monthly_ds__extract_month AS metric_time__extract_month + , subq_4.listing + , subq_4.booking__listing + , subq_4.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -117,20 +117,20 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' - ) subq_2 + ) subq_4 + ) subq_5 + WHERE subq_5.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' + ) subq_6 ON ( - subq_2.metric_time__month <= subq_3.metric_time__month + subq_6.metric_time__month <= subq_7.metric_time__month ) AND ( - subq_2.metric_time__month > subq_3.metric_time__month - MAKE_INTERVAL(months => 3) + subq_6.metric_time__month > subq_7.metric_time__month - MAKE_INTERVAL(months => 3) ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' - ) subq_7 + ) subq_9 + ) subq_10 + WHERE subq_10.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' + ) subq_11 GROUP BY - subq_7.metric_time__month -) subq_8 + subq_11.metric_time__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0_optimized.sql index 96c1cc7f0b..59109e02ce 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.bookings_monthly) AS trailing_3_months_bookings + subq_16.metric_time__month AS metric_time__month + , SUM(subq_15.bookings_monthly) AS trailing_3_months_bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_17 WHERE ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY DATE_TRUNC('month', ds) -) subq_12 +) subq_16 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_monthly_source' -- Metric Time Dimension 'monthly_ds' @@ -24,13 +24,13 @@ INNER JOIN ( , bookings_monthly FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 WHERE DATE_TRUNC('month', ds) BETWEEN '2019-12-05' AND '2021-01-04' -) subq_11 +) subq_15 ON ( - subq_11.metric_time__month <= subq_12.metric_time__month + subq_15.metric_time__month <= subq_16.metric_time__month ) AND ( - subq_11.metric_time__month > subq_12.metric_time__month - MAKE_INTERVAL(months => 3) + subq_15.metric_time__month > subq_16.metric_time__month - MAKE_INTERVAL(months => 3) ) -WHERE subq_12.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' +WHERE subq_16.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - subq_12.metric_time__month + subq_16.metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0.sql index 740a8baf27..089925950f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0.sql @@ -1,83 +1,83 @@ -- Compute Metrics via Expressions SELECT - subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - SUM(subq_2.txn_revenue) AS txn_revenue + SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue',] SELECT - subq_1.txn_revenue + subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 -) subq_3 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0_optimized.sql index e26a1bdb3d..4a0d5baff3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0_optimized.sql @@ -5,4 +5,4 @@ -- Compute Metrics via Expressions SELECT SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0.sql index c134310b8b..8aaa691cd5 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_all_time + subq_12.ds__month + , subq_12.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__month -) subq_3 + subq_11.ds__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0_optimized.sql index a7ca78d4e5..05e48cdae3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 61b9bcc9ac..f781a5a6f4 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -1,187 +1,187 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.txn_revenue AS revenue_all_time + subq_19.metric_time__month + , subq_19.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__month + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.txn_revenue + subq_17.metric_time__month + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.txn_revenue + subq_16.metric_time__month + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__day AS metric_time__day - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__month AS metric_time__month + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__day AS metric_time__day + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_4.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + DATE_TRUNC('month', subq_15.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - DATE_TRUNC('month', subq_4.ds) - ) subq_3 + DATE_TRUNC('month', subq_15.ds) + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' + ) subq_13 ON - (subq_2.metric_time__month <= subq_3.metric_time__month) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_7 + (subq_13.metric_time__month <= subq_14.metric_time__month) + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_18 GROUP BY - subq_7.metric_time__month -) subq_8 + subq_18.metric_time__month +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index a4e5bf994b..0267f01b4a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.txn_revenue) AS revenue_all_time + subq_23.metric_time__month AS metric_time__month + , SUM(subq_22.txn_revenue) AS revenue_all_time FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', ds) -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -22,11 +22,11 @@ INNER JOIN ( SELECT DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' -) subq_11 +) subq_22 ON - (subq_11.metric_time__month <= subq_12.metric_time__month) -WHERE subq_12.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + (subq_22.metric_time__month <= subq_23.metric_time__month) +WHERE subq_23.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_12.metric_time__month + subq_23.metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0.sql index cbf535c48f..98f9b3cdce 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0.sql @@ -1,140 +1,140 @@ -- Compute Metrics via Expressions SELECT - subq_6.revenue_instance__ds__day - , subq_6.txn_revenue AS trailing_2_months_revenue + subq_15.revenue_instance__ds__day + , subq_15.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_5.revenue_instance__ds__day - , SUM(subq_5.txn_revenue) AS txn_revenue + subq_14.revenue_instance__ds__day + , SUM(subq_14.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'revenue_instance__ds__day'] SELECT - subq_4.revenue_instance__ds__day - , subq_4.txn_revenue + subq_13.revenue_instance__ds__day + , subq_13.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_1.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.user AS user - , subq_1.revenue_instance__user AS revenue_instance__user - , subq_1.txn_revenue AS txn_revenue + subq_11.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_10.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_10.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_10.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_10.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_10.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_10.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_10.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_10.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_10.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.user AS user + , subq_10.revenue_instance__user AS revenue_instance__user + , subq_10.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS revenue_instance__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 ON ( - subq_1.revenue_instance__ds__day <= subq_2.revenue_instance__ds__day + subq_10.revenue_instance__ds__day <= subq_11.revenue_instance__ds__day ) AND ( - subq_1.revenue_instance__ds__day > subq_2.revenue_instance__ds__day - MAKE_INTERVAL(months => 2) + subq_10.revenue_instance__ds__day > subq_11.revenue_instance__ds__day - MAKE_INTERVAL(months => 2) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY - subq_5.revenue_instance__ds__day -) subq_6 + subq_14.revenue_instance__ds__day +) subq_15 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql index 6a552ea045..36bf6ebf13 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql @@ -3,16 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ds AS revenue_instance__ds__day - , SUM(revenue_src_28007.revenue) AS trailing_2_months_revenue -FROM ***************************.mf_time_spine subq_10 + subq_19.ds AS revenue_instance__ds__day + , SUM(revenue_src_28000.revenue) AS trailing_2_months_revenue +FROM ***************************.mf_time_spine subq_19 INNER JOIN - ***************************.fct_revenue revenue_src_28007 + ***************************.fct_revenue revenue_src_28000 ON ( - DATE_TRUNC('day', revenue_src_28007.created_at) <= subq_10.ds + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_19.ds ) AND ( - DATE_TRUNC('day', revenue_src_28007.created_at) > subq_10.ds - MAKE_INTERVAL(months => 2) + DATE_TRUNC('day', revenue_src_28000.created_at) > subq_19.ds - MAKE_INTERVAL(months => 2) ) GROUP BY - subq_10.ds + subq_19.ds diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index d7619f64dc..b858211503 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -1,334 +1,334 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.bookers AS every_two_days_bookers + subq_16.metric_time__day + , subq_16.bookers AS every_two_days_bookers FROM ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , COUNT(DISTINCT subq_6.bookers) AS bookers + subq_15.metric_time__day + , COUNT(DISTINCT subq_15.bookers) AS bookers FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.bookers + subq_14.metric_time__day + , subq_14.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > subq_2.metric_time__day - MAKE_INTERVAL(days => 2) + subq_10.metric_time__day > subq_11.metric_time__day - MAKE_INTERVAL(days => 2) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' - ) subq_6 + ) subq_15 GROUP BY - subq_6.metric_time__day -) subq_7 + subq_15.metric_time__day +) subq_16 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index e5c6c927b9..ae89676933 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -8,18 +8,18 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_11.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_20 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_11.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_20.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > subq_11.ds - MAKE_INTERVAL(days => 2) + DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_20.ds - MAKE_INTERVAL(days => 2) ) -) subq_13 +) subq_22 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql index 034096cfd6..6e3c3caeff 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql @@ -1,189 +1,189 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.txn_revenue AS trailing_2_months_revenue + subq_19.metric_time__day + , subq_19.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__day + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__day - , subq_6.txn_revenue + subq_17.metric_time__day + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.txn_revenue + subq_16.metric_time__day + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__day AS metric_time__day - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__month AS metric_time__month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__month AS metric_time__month + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_3 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(isodow FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(isodow FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' + ) subq_13 ON ( - subq_2.metric_time__day <= subq_3.metric_time__day + subq_13.metric_time__day <= subq_14.metric_time__day ) AND ( - subq_2.metric_time__day > subq_3.metric_time__day - MAKE_INTERVAL(months => 2) + subq_13.metric_time__day > subq_14.metric_time__day - MAKE_INTERVAL(months => 2) ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_7 + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_18 GROUP BY - subq_7.metric_time__day -) subq_8 + subq_18.metric_time__day +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 0e6a83d34d..87365ba91b 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -4,15 +4,15 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day AS metric_time__day - , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue + subq_23.metric_time__day AS metric_time__day + , SUM(subq_22.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -20,15 +20,15 @@ INNER JOIN ( SELECT DATE_TRUNC('day', created_at) AS metric_time__day , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' -) subq_11 +) subq_22 ON ( - subq_11.metric_time__day <= subq_12.metric_time__day + subq_22.metric_time__day <= subq_23.metric_time__day ) AND ( - subq_11.metric_time__day > subq_12.metric_time__day - MAKE_INTERVAL(months => 2) + subq_22.metric_time__day > subq_23.metric_time__day - MAKE_INTERVAL(months => 2) ) -WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_23.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_12.metric_time__day + subq_23.metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql index 628e764a09..8924d445aa 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.ds__day + , subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__day + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.txn_revenue + subq_10.ds__day + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__day -) subq_3 + subq_11.ds__day +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0_optimized.sql index 749250c230..76e8f3252a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('day', created_at) AS ds__day , SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('day', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0.sql index 5449f0fd88..0593cab40e 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_mtd + subq_12.ds__month + , subq_12.txn_revenue AS revenue_mtd FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__month -) subq_3 + subq_11.ds__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0_optimized.sql index 6a6dbce8b9..e057084866 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_mtd -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0.sql index 5bc9116fc1..cc865b5b84 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0.sql @@ -1,103 +1,103 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.bookings_monthly AS trailing_3_months_bookings + subq_12.metric_time__month + , subq_12.bookings_monthly AS trailing_3_months_bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.bookings_monthly) AS bookings_monthly + subq_11.metric_time__month + , SUM(subq_11.bookings_monthly) AS bookings_monthly FROM ( -- Constrain Time Range to [2020-03-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly + subq_10.metric_time__month + , subq_10.bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.bookings_monthly + subq_9.metric_time__month + , subq_9.bookings_monthly FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.monthly_ds__month AS monthly_ds__month - , subq_2.monthly_ds__quarter AS monthly_ds__quarter - , subq_2.monthly_ds__year AS monthly_ds__year - , subq_2.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_2.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_2.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_2.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_2.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_2.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_2.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_2.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_2.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.listing AS listing - , subq_2.booking__listing AS booking__listing - , subq_2.bookings_monthly AS bookings_monthly + subq_7.metric_time__month AS metric_time__month + , subq_6.monthly_ds__month AS monthly_ds__month + , subq_6.monthly_ds__quarter AS monthly_ds__quarter + , subq_6.monthly_ds__year AS monthly_ds__year + , subq_6.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_6.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_6.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_6.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_6.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_6.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_6.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_6.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_6.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_6.metric_time__quarter AS metric_time__quarter + , subq_6.metric_time__year AS metric_time__year + , subq_6.metric_time__extract_year AS metric_time__extract_year + , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_6.metric_time__extract_month AS metric_time__extract_month + , subq_6.listing AS listing + , subq_6.booking__listing AS booking__listing + , subq_6.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_4.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-03-05' AND '2021-01-04' + DATE_TRUNC('month', subq_8.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_8 + WHERE subq_8.ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - DATE_TRUNC('month', subq_4.ds) - ) subq_3 + DATE_TRUNC('month', subq_8.ds) + ) subq_7 INNER JOIN ( -- Constrain Time Range to [2019-12-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_1.monthly_ds__month - , subq_1.monthly_ds__quarter - , subq_1.monthly_ds__year - , subq_1.monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month - , subq_1.booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.listing - , subq_1.booking__listing - , subq_1.bookings_monthly + subq_5.monthly_ds__month + , subq_5.monthly_ds__quarter + , subq_5.monthly_ds__year + , subq_5.monthly_ds__extract_year + , subq_5.monthly_ds__extract_quarter + , subq_5.monthly_ds__extract_month + , subq_5.booking__monthly_ds__month + , subq_5.booking__monthly_ds__quarter + , subq_5.booking__monthly_ds__year + , subq_5.booking__monthly_ds__extract_year + , subq_5.booking__monthly_ds__extract_quarter + , subq_5.booking__monthly_ds__extract_month + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.listing + , subq_5.booking__listing + , subq_5.bookings_monthly FROM ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_4.monthly_ds__month + , subq_4.monthly_ds__quarter + , subq_4.monthly_ds__year + , subq_4.monthly_ds__extract_year + , subq_4.monthly_ds__extract_quarter + , subq_4.monthly_ds__extract_month + , subq_4.booking__monthly_ds__month + , subq_4.booking__monthly_ds__quarter + , subq_4.booking__monthly_ds__year + , subq_4.booking__monthly_ds__extract_year + , subq_4.booking__monthly_ds__extract_quarter + , subq_4.booking__monthly_ds__extract_month + , subq_4.monthly_ds__month AS metric_time__month + , subq_4.monthly_ds__quarter AS metric_time__quarter + , subq_4.monthly_ds__year AS metric_time__year + , subq_4.monthly_ds__extract_year AS metric_time__extract_year + , subq_4.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_4.monthly_ds__extract_month AS metric_time__extract_month + , subq_4.listing + , subq_4.booking__listing + , subq_4.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -117,20 +117,20 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' - ) subq_2 + ) subq_4 + ) subq_5 + WHERE subq_5.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' + ) subq_6 ON ( - subq_2.metric_time__month <= subq_3.metric_time__month + subq_6.metric_time__month <= subq_7.metric_time__month ) AND ( - subq_2.metric_time__month > DATEADD(month, -3, subq_3.metric_time__month) + subq_6.metric_time__month > DATEADD(month, -3, subq_7.metric_time__month) ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' - ) subq_7 + ) subq_9 + ) subq_10 + WHERE subq_10.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' + ) subq_11 GROUP BY - subq_7.metric_time__month -) subq_8 + subq_11.metric_time__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0_optimized.sql index 4611f8316c..c9b1da3166 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.bookings_monthly) AS trailing_3_months_bookings + subq_16.metric_time__month AS metric_time__month + , SUM(subq_15.bookings_monthly) AS trailing_3_months_bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_17 WHERE ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY DATE_TRUNC('month', ds) -) subq_12 +) subq_16 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_monthly_source' -- Metric Time Dimension 'monthly_ds' @@ -24,13 +24,13 @@ INNER JOIN ( , bookings_monthly FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 WHERE DATE_TRUNC('month', ds) BETWEEN '2019-12-05' AND '2021-01-04' -) subq_11 +) subq_15 ON ( - subq_11.metric_time__month <= subq_12.metric_time__month + subq_15.metric_time__month <= subq_16.metric_time__month ) AND ( - subq_11.metric_time__month > DATEADD(month, -3, subq_12.metric_time__month) + subq_15.metric_time__month > DATEADD(month, -3, subq_16.metric_time__month) ) -WHERE subq_12.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' +WHERE subq_16.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - subq_12.metric_time__month + subq_16.metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0.sql index adbc914a7a..a1310c81ac 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0.sql @@ -1,83 +1,83 @@ -- Compute Metrics via Expressions SELECT - subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - SUM(subq_2.txn_revenue) AS txn_revenue + SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue',] SELECT - subq_1.txn_revenue + subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 -) subq_3 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0_optimized.sql index e26a1bdb3d..4a0d5baff3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0_optimized.sql @@ -5,4 +5,4 @@ -- Compute Metrics via Expressions SELECT SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0.sql index af069affcc..c97e68cff4 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_all_time + subq_12.ds__month + , subq_12.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__month -) subq_3 + subq_11.ds__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0_optimized.sql index a7ca78d4e5..05e48cdae3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index e9b856ce1a..2d00f83f68 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -1,187 +1,187 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.txn_revenue AS revenue_all_time + subq_19.metric_time__month + , subq_19.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__month + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.txn_revenue + subq_17.metric_time__month + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.txn_revenue + subq_16.metric_time__month + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__day AS metric_time__day - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__month AS metric_time__month + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__day AS metric_time__day + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_4.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + DATE_TRUNC('month', subq_15.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - DATE_TRUNC('month', subq_4.ds) - ) subq_3 + DATE_TRUNC('month', subq_15.ds) + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' + ) subq_13 ON - (subq_2.metric_time__month <= subq_3.metric_time__month) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_7 + (subq_13.metric_time__month <= subq_14.metric_time__month) + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_18 GROUP BY - subq_7.metric_time__month -) subq_8 + subq_18.metric_time__month +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index a4e5bf994b..0267f01b4a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.txn_revenue) AS revenue_all_time + subq_23.metric_time__month AS metric_time__month + , SUM(subq_22.txn_revenue) AS revenue_all_time FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', ds) -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -22,11 +22,11 @@ INNER JOIN ( SELECT DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' -) subq_11 +) subq_22 ON - (subq_11.metric_time__month <= subq_12.metric_time__month) -WHERE subq_12.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + (subq_22.metric_time__month <= subq_23.metric_time__month) +WHERE subq_23.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_12.metric_time__month + subq_23.metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0.sql index 6063a555c2..0d517bc3a0 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0.sql @@ -1,140 +1,140 @@ -- Compute Metrics via Expressions SELECT - subq_6.revenue_instance__ds__day - , subq_6.txn_revenue AS trailing_2_months_revenue + subq_15.revenue_instance__ds__day + , subq_15.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_5.revenue_instance__ds__day - , SUM(subq_5.txn_revenue) AS txn_revenue + subq_14.revenue_instance__ds__day + , SUM(subq_14.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'revenue_instance__ds__day'] SELECT - subq_4.revenue_instance__ds__day - , subq_4.txn_revenue + subq_13.revenue_instance__ds__day + , subq_13.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_1.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.user AS user - , subq_1.revenue_instance__user AS revenue_instance__user - , subq_1.txn_revenue AS txn_revenue + subq_11.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_10.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_10.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_10.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_10.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_10.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_10.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_10.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_10.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_10.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.user AS user + , subq_10.revenue_instance__user AS revenue_instance__user + , subq_10.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS revenue_instance__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 ON ( - subq_1.revenue_instance__ds__day <= subq_2.revenue_instance__ds__day + subq_10.revenue_instance__ds__day <= subq_11.revenue_instance__ds__day ) AND ( - subq_1.revenue_instance__ds__day > DATEADD(month, -2, subq_2.revenue_instance__ds__day) + subq_10.revenue_instance__ds__day > DATEADD(month, -2, subq_11.revenue_instance__ds__day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY - subq_5.revenue_instance__ds__day -) subq_6 + subq_14.revenue_instance__ds__day +) subq_15 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql index 501e54f5dd..9769ddd7de 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql @@ -3,16 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ds AS revenue_instance__ds__day - , SUM(revenue_src_28007.revenue) AS trailing_2_months_revenue -FROM ***************************.mf_time_spine subq_10 + subq_19.ds AS revenue_instance__ds__day + , SUM(revenue_src_28000.revenue) AS trailing_2_months_revenue +FROM ***************************.mf_time_spine subq_19 INNER JOIN - ***************************.fct_revenue revenue_src_28007 + ***************************.fct_revenue revenue_src_28000 ON ( - DATE_TRUNC('day', revenue_src_28007.created_at) <= subq_10.ds + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_19.ds ) AND ( - DATE_TRUNC('day', revenue_src_28007.created_at) > DATEADD(month, -2, subq_10.ds) + DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_19.ds) ) GROUP BY - subq_10.ds + subq_19.ds diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index 59ea896bbc..6ea7a1a66e 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -1,334 +1,334 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.bookers AS every_two_days_bookers + subq_16.metric_time__day + , subq_16.bookers AS every_two_days_bookers FROM ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , COUNT(DISTINCT subq_6.bookers) AS bookers + subq_15.metric_time__day + , COUNT(DISTINCT subq_15.bookers) AS bookers FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.bookers + subq_14.metric_time__day + , subq_14.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -2, subq_11.metric_time__day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' - ) subq_6 + ) subq_15 GROUP BY - subq_6.metric_time__day -) subq_7 + subq_15.metric_time__day +) subq_16 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index aa43d7d7d6..ab8b4812ed 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -8,18 +8,18 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_11.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_20 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_11.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_20.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATEADD(day, -2, subq_11.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_20.ds) ) -) subq_13 +) subq_22 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql index 0b2cf487c5..cd5b13ebad 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql @@ -1,189 +1,189 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.txn_revenue AS trailing_2_months_revenue + subq_19.metric_time__day + , subq_19.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__day + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__day - , subq_6.txn_revenue + subq_17.metric_time__day + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.txn_revenue + subq_16.metric_time__day + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__day AS metric_time__day - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__month AS metric_time__month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__month AS metric_time__month + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_3 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , CASE WHEN EXTRACT(dow FROM revenue_src_28007.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28007.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28007.created_at) END AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , CASE WHEN EXTRACT(dow FROM revenue_src_28000.created_at) = 0 THEN EXTRACT(dow FROM revenue_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM revenue_src_28000.created_at) END AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' + ) subq_13 ON ( - subq_2.metric_time__day <= subq_3.metric_time__day + subq_13.metric_time__day <= subq_14.metric_time__day ) AND ( - subq_2.metric_time__day > DATEADD(month, -2, subq_3.metric_time__day) + subq_13.metric_time__day > DATEADD(month, -2, subq_14.metric_time__day) ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_7 + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_18 GROUP BY - subq_7.metric_time__day -) subq_8 + subq_18.metric_time__day +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 06ea3f5a91..bb3417f1ce 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -4,15 +4,15 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day AS metric_time__day - , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue + subq_23.metric_time__day AS metric_time__day + , SUM(subq_22.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -20,15 +20,15 @@ INNER JOIN ( SELECT DATE_TRUNC('day', created_at) AS metric_time__day , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' -) subq_11 +) subq_22 ON ( - subq_11.metric_time__day <= subq_12.metric_time__day + subq_22.metric_time__day <= subq_23.metric_time__day ) AND ( - subq_11.metric_time__day > DATEADD(month, -2, subq_12.metric_time__day) + subq_22.metric_time__day > DATEADD(month, -2, subq_23.metric_time__day) ) -WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_23.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_12.metric_time__day + subq_23.metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql index 34a09f54e7..870bfdcfdc 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.ds__day + , subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__day + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.txn_revenue + subq_10.ds__day + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__day -) subq_3 + subq_11.ds__day +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0_optimized.sql index 749250c230..76e8f3252a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('day', created_at) AS ds__day , SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('day', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0.sql index 55b47814b1..2db3813f0a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_mtd + subq_12.ds__month + , subq_12.txn_revenue AS revenue_mtd FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__month -) subq_3 + subq_11.ds__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0_optimized.sql index 6a6dbce8b9..e057084866 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_mtd -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0.sql index 5bc9116fc1..cc865b5b84 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0.sql @@ -1,103 +1,103 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.bookings_monthly AS trailing_3_months_bookings + subq_12.metric_time__month + , subq_12.bookings_monthly AS trailing_3_months_bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.bookings_monthly) AS bookings_monthly + subq_11.metric_time__month + , SUM(subq_11.bookings_monthly) AS bookings_monthly FROM ( -- Constrain Time Range to [2020-03-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly + subq_10.metric_time__month + , subq_10.bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.bookings_monthly + subq_9.metric_time__month + , subq_9.bookings_monthly FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.monthly_ds__month AS monthly_ds__month - , subq_2.monthly_ds__quarter AS monthly_ds__quarter - , subq_2.monthly_ds__year AS monthly_ds__year - , subq_2.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_2.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_2.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_2.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_2.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_2.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_2.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_2.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_2.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.listing AS listing - , subq_2.booking__listing AS booking__listing - , subq_2.bookings_monthly AS bookings_monthly + subq_7.metric_time__month AS metric_time__month + , subq_6.monthly_ds__month AS monthly_ds__month + , subq_6.monthly_ds__quarter AS monthly_ds__quarter + , subq_6.monthly_ds__year AS monthly_ds__year + , subq_6.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_6.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_6.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_6.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_6.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_6.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_6.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_6.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_6.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_6.metric_time__quarter AS metric_time__quarter + , subq_6.metric_time__year AS metric_time__year + , subq_6.metric_time__extract_year AS metric_time__extract_year + , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_6.metric_time__extract_month AS metric_time__extract_month + , subq_6.listing AS listing + , subq_6.booking__listing AS booking__listing + , subq_6.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_4.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-03-05' AND '2021-01-04' + DATE_TRUNC('month', subq_8.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_8 + WHERE subq_8.ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - DATE_TRUNC('month', subq_4.ds) - ) subq_3 + DATE_TRUNC('month', subq_8.ds) + ) subq_7 INNER JOIN ( -- Constrain Time Range to [2019-12-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_1.monthly_ds__month - , subq_1.monthly_ds__quarter - , subq_1.monthly_ds__year - , subq_1.monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month - , subq_1.booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.listing - , subq_1.booking__listing - , subq_1.bookings_monthly + subq_5.monthly_ds__month + , subq_5.monthly_ds__quarter + , subq_5.monthly_ds__year + , subq_5.monthly_ds__extract_year + , subq_5.monthly_ds__extract_quarter + , subq_5.monthly_ds__extract_month + , subq_5.booking__monthly_ds__month + , subq_5.booking__monthly_ds__quarter + , subq_5.booking__monthly_ds__year + , subq_5.booking__monthly_ds__extract_year + , subq_5.booking__monthly_ds__extract_quarter + , subq_5.booking__monthly_ds__extract_month + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.listing + , subq_5.booking__listing + , subq_5.bookings_monthly FROM ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_4.monthly_ds__month + , subq_4.monthly_ds__quarter + , subq_4.monthly_ds__year + , subq_4.monthly_ds__extract_year + , subq_4.monthly_ds__extract_quarter + , subq_4.monthly_ds__extract_month + , subq_4.booking__monthly_ds__month + , subq_4.booking__monthly_ds__quarter + , subq_4.booking__monthly_ds__year + , subq_4.booking__monthly_ds__extract_year + , subq_4.booking__monthly_ds__extract_quarter + , subq_4.booking__monthly_ds__extract_month + , subq_4.monthly_ds__month AS metric_time__month + , subq_4.monthly_ds__quarter AS metric_time__quarter + , subq_4.monthly_ds__year AS metric_time__year + , subq_4.monthly_ds__extract_year AS metric_time__extract_year + , subq_4.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_4.monthly_ds__extract_month AS metric_time__extract_month + , subq_4.listing + , subq_4.booking__listing + , subq_4.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -117,20 +117,20 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' - ) subq_2 + ) subq_4 + ) subq_5 + WHERE subq_5.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' + ) subq_6 ON ( - subq_2.metric_time__month <= subq_3.metric_time__month + subq_6.metric_time__month <= subq_7.metric_time__month ) AND ( - subq_2.metric_time__month > DATEADD(month, -3, subq_3.metric_time__month) + subq_6.metric_time__month > DATEADD(month, -3, subq_7.metric_time__month) ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' - ) subq_7 + ) subq_9 + ) subq_10 + WHERE subq_10.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' + ) subq_11 GROUP BY - subq_7.metric_time__month -) subq_8 + subq_11.metric_time__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0_optimized.sql index 4611f8316c..c9b1da3166 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.bookings_monthly) AS trailing_3_months_bookings + subq_16.metric_time__month AS metric_time__month + , SUM(subq_15.bookings_monthly) AS trailing_3_months_bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_17 WHERE ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY DATE_TRUNC('month', ds) -) subq_12 +) subq_16 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_monthly_source' -- Metric Time Dimension 'monthly_ds' @@ -24,13 +24,13 @@ INNER JOIN ( , bookings_monthly FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 WHERE DATE_TRUNC('month', ds) BETWEEN '2019-12-05' AND '2021-01-04' -) subq_11 +) subq_15 ON ( - subq_11.metric_time__month <= subq_12.metric_time__month + subq_15.metric_time__month <= subq_16.metric_time__month ) AND ( - subq_11.metric_time__month > DATEADD(month, -3, subq_12.metric_time__month) + subq_15.metric_time__month > DATEADD(month, -3, subq_16.metric_time__month) ) -WHERE subq_12.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' +WHERE subq_16.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - subq_12.metric_time__month + subq_16.metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0.sql index 8bc130fbf5..251bc5a79f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0.sql @@ -1,83 +1,83 @@ -- Compute Metrics via Expressions SELECT - subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - SUM(subq_2.txn_revenue) AS txn_revenue + SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue',] SELECT - subq_1.txn_revenue + subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 -) subq_3 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0_optimized.sql index e26a1bdb3d..4a0d5baff3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0_optimized.sql @@ -5,4 +5,4 @@ -- Compute Metrics via Expressions SELECT SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0.sql index dfc1d734e7..55e6b58ce9 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_all_time + subq_12.ds__month + , subq_12.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__month -) subq_3 + subq_11.ds__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0_optimized.sql index a7ca78d4e5..05e48cdae3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 5e5336aedd..fed3314007 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -1,187 +1,187 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.txn_revenue AS revenue_all_time + subq_19.metric_time__month + , subq_19.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__month + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.txn_revenue + subq_17.metric_time__month + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.txn_revenue + subq_16.metric_time__month + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__day AS metric_time__day - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__month AS metric_time__month + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__day AS metric_time__day + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_4.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + DATE_TRUNC('month', subq_15.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - DATE_TRUNC('month', subq_4.ds) - ) subq_3 + DATE_TRUNC('month', subq_15.ds) + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' + ) subq_13 ON - (subq_2.metric_time__month <= subq_3.metric_time__month) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_7 + (subq_13.metric_time__month <= subq_14.metric_time__month) + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_18 GROUP BY - subq_7.metric_time__month -) subq_8 + subq_18.metric_time__month +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index a4e5bf994b..0267f01b4a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.txn_revenue) AS revenue_all_time + subq_23.metric_time__month AS metric_time__month + , SUM(subq_22.txn_revenue) AS revenue_all_time FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', ds) -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -22,11 +22,11 @@ INNER JOIN ( SELECT DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' -) subq_11 +) subq_22 ON - (subq_11.metric_time__month <= subq_12.metric_time__month) -WHERE subq_12.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + (subq_22.metric_time__month <= subq_23.metric_time__month) +WHERE subq_23.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_12.metric_time__month + subq_23.metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0.sql index 22100cdf6e..0d10f13418 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0.sql @@ -1,140 +1,140 @@ -- Compute Metrics via Expressions SELECT - subq_6.revenue_instance__ds__day - , subq_6.txn_revenue AS trailing_2_months_revenue + subq_15.revenue_instance__ds__day + , subq_15.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_5.revenue_instance__ds__day - , SUM(subq_5.txn_revenue) AS txn_revenue + subq_14.revenue_instance__ds__day + , SUM(subq_14.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'revenue_instance__ds__day'] SELECT - subq_4.revenue_instance__ds__day - , subq_4.txn_revenue + subq_13.revenue_instance__ds__day + , subq_13.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_1.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.user AS user - , subq_1.revenue_instance__user AS revenue_instance__user - , subq_1.txn_revenue AS txn_revenue + subq_11.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_10.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_10.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_10.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_10.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_10.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_10.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_10.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_10.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_10.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.user AS user + , subq_10.revenue_instance__user AS revenue_instance__user + , subq_10.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS revenue_instance__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 ON ( - subq_1.revenue_instance__ds__day <= subq_2.revenue_instance__ds__day + subq_10.revenue_instance__ds__day <= subq_11.revenue_instance__ds__day ) AND ( - subq_1.revenue_instance__ds__day > DATEADD(month, -2, subq_2.revenue_instance__ds__day) + subq_10.revenue_instance__ds__day > DATEADD(month, -2, subq_11.revenue_instance__ds__day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY - subq_5.revenue_instance__ds__day -) subq_6 + subq_14.revenue_instance__ds__day +) subq_15 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql index 501e54f5dd..9769ddd7de 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql @@ -3,16 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ds AS revenue_instance__ds__day - , SUM(revenue_src_28007.revenue) AS trailing_2_months_revenue -FROM ***************************.mf_time_spine subq_10 + subq_19.ds AS revenue_instance__ds__day + , SUM(revenue_src_28000.revenue) AS trailing_2_months_revenue +FROM ***************************.mf_time_spine subq_19 INNER JOIN - ***************************.fct_revenue revenue_src_28007 + ***************************.fct_revenue revenue_src_28000 ON ( - DATE_TRUNC('day', revenue_src_28007.created_at) <= subq_10.ds + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_19.ds ) AND ( - DATE_TRUNC('day', revenue_src_28007.created_at) > DATEADD(month, -2, subq_10.ds) + DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_19.ds) ) GROUP BY - subq_10.ds + subq_19.ds diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index c888543562..e7c67ad1f2 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -1,334 +1,334 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.bookers AS every_two_days_bookers + subq_16.metric_time__day + , subq_16.bookers AS every_two_days_bookers FROM ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , COUNT(DISTINCT subq_6.bookers) AS bookers + subq_15.metric_time__day + , COUNT(DISTINCT subq_15.bookers) AS bookers FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.bookers + subq_14.metric_time__day + , subq_14.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -2, subq_11.metric_time__day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' - ) subq_6 + ) subq_15 GROUP BY - subq_6.metric_time__day -) subq_7 + subq_15.metric_time__day +) subq_16 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index aa43d7d7d6..ab8b4812ed 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -8,18 +8,18 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_11.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_20 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_11.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_20.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATEADD(day, -2, subq_11.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_20.ds) ) -) subq_13 +) subq_22 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql index 0720bd2b47..aa231c3d04 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql @@ -1,189 +1,189 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.txn_revenue AS trailing_2_months_revenue + subq_19.metric_time__day + , subq_19.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__day + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__day - , subq_6.txn_revenue + subq_17.metric_time__day + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.txn_revenue + subq_16.metric_time__day + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__day AS metric_time__day - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__month AS metric_time__month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__month AS metric_time__month + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_3 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(dayofweekiso FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(dayofweekiso FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' + ) subq_13 ON ( - subq_2.metric_time__day <= subq_3.metric_time__day + subq_13.metric_time__day <= subq_14.metric_time__day ) AND ( - subq_2.metric_time__day > DATEADD(month, -2, subq_3.metric_time__day) + subq_13.metric_time__day > DATEADD(month, -2, subq_14.metric_time__day) ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_7 + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_18 GROUP BY - subq_7.metric_time__day -) subq_8 + subq_18.metric_time__day +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 06ea3f5a91..bb3417f1ce 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -4,15 +4,15 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day AS metric_time__day - , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue + subq_23.metric_time__day AS metric_time__day + , SUM(subq_22.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -20,15 +20,15 @@ INNER JOIN ( SELECT DATE_TRUNC('day', created_at) AS metric_time__day , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' -) subq_11 +) subq_22 ON ( - subq_11.metric_time__day <= subq_12.metric_time__day + subq_22.metric_time__day <= subq_23.metric_time__day ) AND ( - subq_11.metric_time__day > DATEADD(month, -2, subq_12.metric_time__day) + subq_22.metric_time__day > DATEADD(month, -2, subq_23.metric_time__day) ) -WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_23.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_12.metric_time__day + subq_23.metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric__plan0.sql index 8b87e57774..ccda7dabbc 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.ds__day + , subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__day + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.txn_revenue + subq_10.ds__day + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__day -) subq_3 + subq_11.ds__day +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric__plan0_optimized.sql index 749250c230..76e8f3252a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('day', created_at) AS ds__day , SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('day', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_grain_to_date__plan0.sql index c3cdc082eb..b2a1f37b3f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_grain_to_date__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_mtd + subq_12.ds__month + , subq_12.txn_revenue AS revenue_mtd FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__month -) subq_3 + subq_11.ds__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_grain_to_date__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_grain_to_date__plan0_optimized.sql index 6a6dbce8b9..e057084866 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_grain_to_date__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_grain_to_date__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_mtd -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0.sql index 8423ed8494..cab7f99b7f 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0.sql @@ -1,103 +1,103 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.bookings_monthly AS trailing_3_months_bookings + subq_12.metric_time__month + , subq_12.bookings_monthly AS trailing_3_months_bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.bookings_monthly) AS bookings_monthly + subq_11.metric_time__month + , SUM(subq_11.bookings_monthly) AS bookings_monthly FROM ( -- Constrain Time Range to [2020-03-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly + subq_10.metric_time__month + , subq_10.bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.bookings_monthly + subq_9.metric_time__month + , subq_9.bookings_monthly FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.monthly_ds__month AS monthly_ds__month - , subq_2.monthly_ds__quarter AS monthly_ds__quarter - , subq_2.monthly_ds__year AS monthly_ds__year - , subq_2.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_2.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_2.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_2.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_2.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_2.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_2.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_2.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_2.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.listing AS listing - , subq_2.booking__listing AS booking__listing - , subq_2.bookings_monthly AS bookings_monthly + subq_7.metric_time__month AS metric_time__month + , subq_6.monthly_ds__month AS monthly_ds__month + , subq_6.monthly_ds__quarter AS monthly_ds__quarter + , subq_6.monthly_ds__year AS monthly_ds__year + , subq_6.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_6.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_6.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_6.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_6.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_6.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_6.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_6.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_6.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_6.metric_time__quarter AS metric_time__quarter + , subq_6.metric_time__year AS metric_time__year + , subq_6.metric_time__extract_year AS metric_time__extract_year + , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_6.metric_time__extract_month AS metric_time__extract_month + , subq_6.listing AS listing + , subq_6.booking__listing AS booking__listing + , subq_6.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_4.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' + DATE_TRUNC('month', subq_8.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_8 + WHERE subq_8.ds BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' GROUP BY - DATE_TRUNC('month', subq_4.ds) - ) subq_3 + DATE_TRUNC('month', subq_8.ds) + ) subq_7 INNER JOIN ( -- Constrain Time Range to [2019-12-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_1.monthly_ds__month - , subq_1.monthly_ds__quarter - , subq_1.monthly_ds__year - , subq_1.monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month - , subq_1.booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.listing - , subq_1.booking__listing - , subq_1.bookings_monthly + subq_5.monthly_ds__month + , subq_5.monthly_ds__quarter + , subq_5.monthly_ds__year + , subq_5.monthly_ds__extract_year + , subq_5.monthly_ds__extract_quarter + , subq_5.monthly_ds__extract_month + , subq_5.booking__monthly_ds__month + , subq_5.booking__monthly_ds__quarter + , subq_5.booking__monthly_ds__year + , subq_5.booking__monthly_ds__extract_year + , subq_5.booking__monthly_ds__extract_quarter + , subq_5.booking__monthly_ds__extract_month + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.listing + , subq_5.booking__listing + , subq_5.bookings_monthly FROM ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_4.monthly_ds__month + , subq_4.monthly_ds__quarter + , subq_4.monthly_ds__year + , subq_4.monthly_ds__extract_year + , subq_4.monthly_ds__extract_quarter + , subq_4.monthly_ds__extract_month + , subq_4.booking__monthly_ds__month + , subq_4.booking__monthly_ds__quarter + , subq_4.booking__monthly_ds__year + , subq_4.booking__monthly_ds__extract_year + , subq_4.booking__monthly_ds__extract_quarter + , subq_4.booking__monthly_ds__extract_month + , subq_4.monthly_ds__month AS metric_time__month + , subq_4.monthly_ds__quarter AS metric_time__quarter + , subq_4.monthly_ds__year AS metric_time__year + , subq_4.monthly_ds__extract_year AS metric_time__extract_year + , subq_4.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_4.monthly_ds__extract_month AS metric_time__extract_month + , subq_4.listing + , subq_4.booking__listing + , subq_4.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -117,20 +117,20 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__month BETWEEN timestamp '2019-12-05' AND timestamp '2021-01-04' - ) subq_2 + ) subq_4 + ) subq_5 + WHERE subq_5.metric_time__month BETWEEN timestamp '2019-12-05' AND timestamp '2021-01-04' + ) subq_6 ON ( - subq_2.metric_time__month <= subq_3.metric_time__month + subq_6.metric_time__month <= subq_7.metric_time__month ) AND ( - subq_2.metric_time__month > DATE_ADD('month', -3, subq_3.metric_time__month) + subq_6.metric_time__month > DATE_ADD('month', -3, subq_7.metric_time__month) ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' - ) subq_7 + ) subq_9 + ) subq_10 + WHERE subq_10.metric_time__month BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' + ) subq_11 GROUP BY - subq_7.metric_time__month -) subq_8 + subq_11.metric_time__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0_optimized.sql index edd17f3f71..aace0fbfd7 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.bookings_monthly) AS trailing_3_months_bookings + subq_16.metric_time__month AS metric_time__month + , SUM(subq_15.bookings_monthly) AS trailing_3_months_bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_17 WHERE ds BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' GROUP BY DATE_TRUNC('month', ds) -) subq_12 +) subq_16 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_monthly_source' -- Metric Time Dimension 'monthly_ds' @@ -24,13 +24,13 @@ INNER JOIN ( , bookings_monthly FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 WHERE DATE_TRUNC('month', ds) BETWEEN timestamp '2019-12-05' AND timestamp '2021-01-04' -) subq_11 +) subq_15 ON ( - subq_11.metric_time__month <= subq_12.metric_time__month + subq_15.metric_time__month <= subq_16.metric_time__month ) AND ( - subq_11.metric_time__month > DATE_ADD('month', -3, subq_12.metric_time__month) + subq_15.metric_time__month > DATE_ADD('month', -3, subq_16.metric_time__month) ) -WHERE subq_12.metric_time__month BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' +WHERE subq_16.metric_time__month BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' GROUP BY - subq_12.metric_time__month + subq_16.metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_ds__plan0.sql index e38d3d81a3..6beb28db7a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_ds__plan0.sql @@ -1,83 +1,83 @@ -- Compute Metrics via Expressions SELECT - subq_3.txn_revenue AS trailing_2_months_revenue + subq_12.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - SUM(subq_2.txn_revenue) AS txn_revenue + SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue',] SELECT - subq_1.txn_revenue + subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 -) subq_3 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_ds__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_ds__plan0_optimized.sql index e26a1bdb3d..4a0d5baff3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_ds__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_ds__plan0_optimized.sql @@ -5,4 +5,4 @@ -- Compute Metrics via Expressions SELECT SUM(revenue) AS trailing_2_months_revenue -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window__plan0.sql index f6c99d18f9..1b2358a291 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window__plan0.sql @@ -1,88 +1,88 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month - , subq_3.txn_revenue AS revenue_all_time + subq_12.ds__month + , subq_12.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_2.ds__month - , SUM(subq_2.txn_revenue) AS txn_revenue + subq_11.ds__month + , SUM(subq_11.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'ds__month'] SELECT - subq_1.ds__month - , subq_1.txn_revenue + subq_10.ds__month + , subq_10.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__month -) subq_3 + subq_11.ds__month +) subq_12 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window__plan0_optimized.sql index a7ca78d4e5..05e48cdae3 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window__plan0_optimized.sql @@ -6,6 +6,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time -FROM ***************************.fct_revenue revenue_src_28007 +FROM ***************************.fct_revenue revenue_src_28000 GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 6e4cc27833..57d268ed29 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -1,187 +1,187 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.txn_revenue AS revenue_all_time + subq_19.metric_time__month + , subq_19.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__month + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__month - , subq_6.txn_revenue + subq_17.metric_time__month + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] SELECT - subq_5.metric_time__month - , subq_5.txn_revenue + subq_16.metric_time__month + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__month AS metric_time__month - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__day AS metric_time__day - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__month AS metric_time__month + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__day AS metric_time__day + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_4.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + DATE_TRUNC('month', subq_15.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' GROUP BY - DATE_TRUNC('month', subq_4.ds) - ) subq_3 + DATE_TRUNC('month', subq_15.ds) + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN timestamp '2000-01-01' AND timestamp '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN timestamp '2000-01-01' AND timestamp '2020-01-01' + ) subq_13 ON - (subq_2.metric_time__month <= subq_3.metric_time__month) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__month BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' - ) subq_7 + (subq_13.metric_time__month <= subq_14.metric_time__month) + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__month BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + ) subq_18 GROUP BY - subq_7.metric_time__month -) subq_8 + subq_18.metric_time__month +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 681918b712..767f1f424b 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__month AS metric_time__month - , SUM(subq_11.txn_revenue) AS revenue_all_time + subq_23.metric_time__month AS metric_time__month + , SUM(subq_22.txn_revenue) AS revenue_all_time FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' GROUP BY DATE_TRUNC('month', ds) -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -22,11 +22,11 @@ INNER JOIN ( SELECT DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN timestamp '2000-01-01' AND timestamp '2020-01-01' -) subq_11 +) subq_22 ON - (subq_11.metric_time__month <= subq_12.metric_time__month) -WHERE subq_12.metric_time__month BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + (subq_22.metric_time__month <= subq_23.metric_time__month) +WHERE subq_23.metric_time__month BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' GROUP BY - subq_12.metric_time__month + subq_23.metric_time__month diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0.sql index 44ed3501a2..eb8f85ceb2 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0.sql @@ -1,140 +1,140 @@ -- Compute Metrics via Expressions SELECT - subq_6.revenue_instance__ds__day - , subq_6.txn_revenue AS trailing_2_months_revenue + subq_15.revenue_instance__ds__day + , subq_15.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_5.revenue_instance__ds__day - , SUM(subq_5.txn_revenue) AS txn_revenue + subq_14.revenue_instance__ds__day + , SUM(subq_14.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'revenue_instance__ds__day'] SELECT - subq_4.revenue_instance__ds__day - , subq_4.txn_revenue + subq_13.revenue_instance__ds__day + , subq_13.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_1.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.user AS user - , subq_1.revenue_instance__user AS revenue_instance__user - , subq_1.txn_revenue AS txn_revenue + subq_11.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_10.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_10.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_10.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_10.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_10.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_10.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_10.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_10.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_10.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.user AS user + , subq_10.revenue_instance__user AS revenue_instance__user + , subq_10.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS revenue_instance__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.revenue_instance__ds__day + , subq_9.revenue_instance__ds__week + , subq_9.revenue_instance__ds__month + , subq_9.revenue_instance__ds__quarter + , subq_9.revenue_instance__ds__year + , subq_9.revenue_instance__ds__extract_year + , subq_9.revenue_instance__ds__extract_quarter + , subq_9.revenue_instance__ds__extract_month + , subq_9.revenue_instance__ds__extract_day + , subq_9.revenue_instance__ds__extract_dow + , subq_9.revenue_instance__ds__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.user + , subq_9.revenue_instance__user + , subq_9.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_9 + ) subq_10 ON ( - subq_1.revenue_instance__ds__day <= subq_2.revenue_instance__ds__day + subq_10.revenue_instance__ds__day <= subq_11.revenue_instance__ds__day ) AND ( - subq_1.revenue_instance__ds__day > DATE_ADD('month', -2, subq_2.revenue_instance__ds__day) + subq_10.revenue_instance__ds__day > DATE_ADD('month', -2, subq_11.revenue_instance__ds__day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY - subq_5.revenue_instance__ds__day -) subq_6 + subq_14.revenue_instance__ds__day +) subq_15 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql index 3a1a9a5fd9..b5c2bc5f23 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql @@ -3,16 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ds AS revenue_instance__ds__day - , SUM(revenue_src_28007.revenue) AS trailing_2_months_revenue -FROM ***************************.mf_time_spine subq_10 + subq_19.ds AS revenue_instance__ds__day + , SUM(revenue_src_28000.revenue) AS trailing_2_months_revenue +FROM ***************************.mf_time_spine subq_19 INNER JOIN - ***************************.fct_revenue revenue_src_28007 + ***************************.fct_revenue revenue_src_28000 ON ( - DATE_TRUNC('day', revenue_src_28007.created_at) <= subq_10.ds + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_19.ds ) AND ( - DATE_TRUNC('day', revenue_src_28007.created_at) > DATE_ADD('month', -2, subq_10.ds) + DATE_TRUNC('day', revenue_src_28000.created_at) > DATE_ADD('month', -2, subq_19.ds) ) GROUP BY - subq_10.ds + subq_19.ds diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index eb8304ee50..863dfcfc8d 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -1,334 +1,334 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.bookers AS every_two_days_bookers + subq_16.metric_time__day + , subq_16.bookers AS every_two_days_bookers FROM ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , COUNT(DISTINCT subq_6.bookers) AS bookers + subq_15.metric_time__day + , COUNT(DISTINCT subq_15.bookers) AS bookers FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.bookers + subq_14.metric_time__day + , subq_14.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATE_ADD('day', -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATE_ADD('day', -2, subq_11.metric_time__day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' - ) subq_6 + ) subq_15 GROUP BY - subq_6.metric_time__day -) subq_7 + subq_15.metric_time__day +) subq_16 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index a58cde372e..226c7dbb63 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -8,18 +8,18 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_11.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_20 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_11.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_20.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATE_ADD('day', -2, subq_11.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_20.ds) ) -) subq_13 +) subq_22 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql index 9ee18fafc9..f8435e06c4 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql @@ -1,189 +1,189 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.txn_revenue AS trailing_2_months_revenue + subq_19.metric_time__day + , subq_19.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.txn_revenue) AS txn_revenue + subq_18.metric_time__day + , SUM(subq_18.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__day - , subq_6.txn_revenue + subq_17.metric_time__day + , subq_17.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.txn_revenue + subq_16.metric_time__day + , subq_16.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_3.metric_time__day AS metric_time__day - , subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_2.metric_time__week AS metric_time__week - , subq_2.metric_time__month AS metric_time__month - , subq_2.metric_time__quarter AS metric_time__quarter - , subq_2.metric_time__year AS metric_time__year - , subq_2.metric_time__extract_year AS metric_time__extract_year - , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_2.metric_time__extract_month AS metric_time__extract_month - , subq_2.metric_time__extract_day AS metric_time__extract_day - , subq_2.metric_time__extract_dow AS metric_time__extract_dow - , subq_2.metric_time__extract_doy AS metric_time__extract_doy - , subq_2.user AS user - , subq_2.revenue_instance__user AS revenue_instance__user - , subq_2.txn_revenue AS txn_revenue + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_13.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_13.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_13.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_13.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_13.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_13.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_13.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_13.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_13.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_13.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_13.metric_time__week AS metric_time__week + , subq_13.metric_time__month AS metric_time__month + , subq_13.metric_time__quarter AS metric_time__quarter + , subq_13.metric_time__year AS metric_time__year + , subq_13.metric_time__extract_year AS metric_time__extract_year + , subq_13.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_13.metric_time__extract_month AS metric_time__extract_month + , subq_13.metric_time__extract_day AS metric_time__extract_day + , subq_13.metric_time__extract_dow AS metric_time__extract_dow + , subq_13.metric_time__extract_doy AS metric_time__extract_doy + , subq_13.user AS user + , subq_13.revenue_instance__user AS revenue_instance__user + , subq_13.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_4 - WHERE subq_4.ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' - ) subq_3 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + ) subq_14 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.revenue_instance__ds__day - , subq_1.revenue_instance__ds__week - , subq_1.revenue_instance__ds__month - , subq_1.revenue_instance__ds__quarter - , subq_1.revenue_instance__ds__year - , subq_1.revenue_instance__ds__extract_year - , subq_1.revenue_instance__ds__extract_quarter - , subq_1.revenue_instance__ds__extract_month - , subq_1.revenue_instance__ds__extract_day - , subq_1.revenue_instance__ds__extract_dow - , subq_1.revenue_instance__ds__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.user - , subq_1.revenue_instance__user - , subq_1.txn_revenue + subq_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.revenue_instance__ds__day + , subq_12.revenue_instance__ds__week + , subq_12.revenue_instance__ds__month + , subq_12.revenue_instance__ds__quarter + , subq_12.revenue_instance__ds__year + , subq_12.revenue_instance__ds__extract_year + , subq_12.revenue_instance__ds__extract_quarter + , subq_12.revenue_instance__ds__extract_month + , subq_12.revenue_instance__ds__extract_day + , subq_12.revenue_instance__ds__extract_dow + , subq_12.revenue_instance__ds__extract_doy + , subq_12.metric_time__day + , subq_12.metric_time__week + , subq_12.metric_time__month + , subq_12.metric_time__quarter + , subq_12.metric_time__year + , subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.user + , subq_12.revenue_instance__user + , subq_12.txn_revenue 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.revenue_instance__ds__day - , subq_0.revenue_instance__ds__week - , subq_0.revenue_instance__ds__month - , subq_0.revenue_instance__ds__quarter - , subq_0.revenue_instance__ds__year - , subq_0.revenue_instance__ds__extract_year - , subq_0.revenue_instance__ds__extract_quarter - , subq_0.revenue_instance__ds__extract_month - , subq_0.revenue_instance__ds__extract_day - , subq_0.revenue_instance__ds__extract_dow - , subq_0.revenue_instance__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.revenue_instance__user - , subq_0.txn_revenue + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.revenue_instance__ds__day + , subq_11.revenue_instance__ds__week + , subq_11.revenue_instance__ds__month + , subq_11.revenue_instance__ds__quarter + , subq_11.revenue_instance__ds__year + , subq_11.revenue_instance__ds__extract_year + , subq_11.revenue_instance__ds__extract_quarter + , subq_11.revenue_instance__ds__extract_month + , subq_11.revenue_instance__ds__extract_day + , subq_11.revenue_instance__ds__extract_dow + , subq_11.revenue_instance__ds__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.user + , subq_11.revenue_instance__user + , subq_11.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT - revenue_src_28007.revenue AS txn_revenue - , DATE_TRUNC('day', revenue_src_28007.created_at) AS ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS ds__extract_doy - , DATE_TRUNC('day', revenue_src_28007.created_at) AS revenue_instance__ds__day - , DATE_TRUNC('week', revenue_src_28007.created_at) AS revenue_instance__ds__week - , DATE_TRUNC('month', revenue_src_28007.created_at) AS revenue_instance__ds__month - , DATE_TRUNC('quarter', revenue_src_28007.created_at) AS revenue_instance__ds__quarter - , DATE_TRUNC('year', revenue_src_28007.created_at) AS revenue_instance__ds__year - , EXTRACT(year FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_year - , EXTRACT(quarter FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_quarter - , EXTRACT(month FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_month - , EXTRACT(day FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_dow - , EXTRACT(doy FROM revenue_src_28007.created_at) AS revenue_instance__ds__extract_doy - , revenue_src_28007.user_id AS user - , revenue_src_28007.user_id AS revenue_instance__user - FROM ***************************.fct_revenue revenue_src_28007 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN timestamp '2019-11-01' AND timestamp '2020-01-01' - ) subq_2 + revenue_src_28000.revenue AS txn_revenue + , DATE_TRUNC('day', revenue_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', revenue_src_28000.created_at) AS revenue_instance__ds__day + , DATE_TRUNC('week', revenue_src_28000.created_at) AS revenue_instance__ds__week + , DATE_TRUNC('month', revenue_src_28000.created_at) AS revenue_instance__ds__month + , DATE_TRUNC('quarter', revenue_src_28000.created_at) AS revenue_instance__ds__quarter + , DATE_TRUNC('year', revenue_src_28000.created_at) AS revenue_instance__ds__year + , EXTRACT(year FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_year + , EXTRACT(quarter FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_quarter + , EXTRACT(month FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_month + , EXTRACT(day FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_dow + , EXTRACT(doy FROM revenue_src_28000.created_at) AS revenue_instance__ds__extract_doy + , revenue_src_28000.user_id AS user + , revenue_src_28000.user_id AS revenue_instance__user + FROM ***************************.fct_revenue revenue_src_28000 + ) subq_11 + ) subq_12 + WHERE subq_12.metric_time__day BETWEEN timestamp '2019-11-01' AND timestamp '2020-01-01' + ) subq_13 ON ( - subq_2.metric_time__day <= subq_3.metric_time__day + subq_13.metric_time__day <= subq_14.metric_time__day ) AND ( - subq_2.metric_time__day > DATE_ADD('month', -2, subq_3.metric_time__day) + subq_13.metric_time__day > DATE_ADD('month', -2, subq_14.metric_time__day) ) - ) subq_5 - ) subq_6 - WHERE subq_6.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' - ) subq_7 + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + ) subq_18 GROUP BY - subq_7.metric_time__day -) subq_8 + subq_18.metric_time__day +) subq_19 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 07971fda92..cddeddf95e 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -4,15 +4,15 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day AS metric_time__day - , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue + subq_23.metric_time__day AS metric_time__day + , SUM(subq_22.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_13 + FROM ***************************.mf_time_spine subq_24 WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' -) subq_12 +) subq_23 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -20,15 +20,15 @@ INNER JOIN ( SELECT DATE_TRUNC('day', created_at) AS metric_time__day , revenue AS txn_revenue - FROM ***************************.fct_revenue revenue_src_28007 + FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN timestamp '2019-11-01' AND timestamp '2020-01-01' -) subq_11 +) subq_22 ON ( - subq_11.metric_time__day <= subq_12.metric_time__day + subq_22.metric_time__day <= subq_23.metric_time__day ) AND ( - subq_11.metric_time__day > DATE_ADD('month', -2, subq_12.metric_time__day) + subq_22.metric_time__day > DATE_ADD('month', -2, subq_23.metric_time__day) ) -WHERE subq_12.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' +WHERE subq_23.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' GROUP BY - subq_12.metric_time__day + subq_23.metric_time__day diff --git a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/BigQuery/test_build_metric_tasks__query0.sql b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/BigQuery/test_build_metric_tasks__query0.sql index f6772ae7c3..49fd5edf06 100644 --- a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/BigQuery/test_build_metric_tasks__query0.sql +++ b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/BigQuery/test_build_metric_tasks__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS count_dogs - FROM ***************************.fct_animals animals_src_0 -) subq_2 + FROM ***************************.fct_animals animals_src_10000 +) subq_3 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Databricks/test_build_metric_tasks__query0.sql b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Databricks/test_build_metric_tasks__query0.sql index a007292bd9..a4dec7ca57 100644 --- a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Databricks/test_build_metric_tasks__query0.sql +++ b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Databricks/test_build_metric_tasks__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS count_dogs - FROM ***************************.fct_animals animals_src_0 -) subq_2 + FROM ***************************.fct_animals animals_src_10000 +) subq_3 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/DuckDB/test_build_metric_tasks__query0.sql b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/DuckDB/test_build_metric_tasks__query0.sql index a007292bd9..a4dec7ca57 100644 --- a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/DuckDB/test_build_metric_tasks__query0.sql +++ b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/DuckDB/test_build_metric_tasks__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS count_dogs - FROM ***************************.fct_animals animals_src_0 -) subq_2 + FROM ***************************.fct_animals animals_src_10000 +) subq_3 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Postgres/test_build_metric_tasks__query0.sql b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Postgres/test_build_metric_tasks__query0.sql index a007292bd9..a4dec7ca57 100644 --- a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Postgres/test_build_metric_tasks__query0.sql +++ b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Postgres/test_build_metric_tasks__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS count_dogs - FROM ***************************.fct_animals animals_src_0 -) subq_2 + FROM ***************************.fct_animals animals_src_10000 +) subq_3 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Redshift/test_build_metric_tasks__query0.sql b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Redshift/test_build_metric_tasks__query0.sql index a007292bd9..a4dec7ca57 100644 --- a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Redshift/test_build_metric_tasks__query0.sql +++ b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Redshift/test_build_metric_tasks__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS count_dogs - FROM ***************************.fct_animals animals_src_0 -) subq_2 + FROM ***************************.fct_animals animals_src_10000 +) subq_3 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Snowflake/test_build_metric_tasks__query0.sql b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Snowflake/test_build_metric_tasks__query0.sql index a007292bd9..a4dec7ca57 100644 --- a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Snowflake/test_build_metric_tasks__query0.sql +++ b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Snowflake/test_build_metric_tasks__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS count_dogs - FROM ***************************.fct_animals animals_src_0 -) subq_2 + FROM ***************************.fct_animals animals_src_10000 +) subq_3 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Trino/test_build_metric_tasks__query0.sql b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Trino/test_build_metric_tasks__query0.sql index a007292bd9..a4dec7ca57 100644 --- a/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Trino/test_build_metric_tasks__query0.sql +++ b/metricflow/test/snapshots/test_data_warehouse_tasks.py/str/Trino/test_build_metric_tasks__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS count_dogs - FROM ***************************.fct_animals animals_src_0 -) subq_2 + FROM ***************************.fct_animals animals_src_10000 +) subq_3 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_combined_metrics_plan__ep_0.xml index 40832a68bb..0cf4b800ff 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_combined_metrics_plan__ep_0.xml @@ -2,85 +2,85 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_joined_plan__ep_0.xml index 6e06248f38..9b3a02c32a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_joined_plan__ep_0.xml @@ -8,9 +8,9 @@ - - - + + + @@ -19,12 +19,12 @@ - - + + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml index 758ee8ee45..4ee7fa977d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml @@ -2,40 +2,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_small_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_small_combined_metrics_plan__ep_0.xml index 9d39c9adee..347138a589 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_small_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_small_combined_metrics_plan__ep_0.xml @@ -5,9 +5,9 @@ - - - + + + @@ -21,11 +21,11 @@ - - + + - + @@ -35,12 +35,12 @@ - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_combined_metrics_plan__ep_0.xml index 35d3e1ed33..0d67248318 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_combined_metrics_plan__ep_0.xml @@ -2,85 +2,85 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_joined_plan__ep_0.xml index cf1f368a88..6d31dd15e4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_joined_plan__ep_0.xml @@ -8,9 +8,9 @@ - - - + + + @@ -19,14 +19,14 @@ - - + + - + - + - - + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml index f77cd373c7..381230ff5b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml @@ -2,40 +2,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_small_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_small_combined_metrics_plan__ep_0.xml index a41f3173fe..2c6243fd7e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_small_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_small_combined_metrics_plan__ep_0.xml @@ -5,9 +5,9 @@ - - - + + + @@ -21,11 +21,11 @@ - - + + - + @@ -35,13 +35,13 @@ - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_combined_metrics_plan__ep_0.xml index 35d3e1ed33..0d67248318 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_combined_metrics_plan__ep_0.xml @@ -2,85 +2,85 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_joined_plan__ep_0.xml index cf1f368a88..6d31dd15e4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_joined_plan__ep_0.xml @@ -8,9 +8,9 @@ - - - + + + @@ -19,14 +19,14 @@ - - + + - + - + - - + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_multihop_joined_plan__ep_0.xml index f77cd373c7..381230ff5b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_multihop_joined_plan__ep_0.xml @@ -2,40 +2,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_small_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_small_combined_metrics_plan__ep_0.xml index a41f3173fe..2c6243fd7e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_small_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_small_combined_metrics_plan__ep_0.xml @@ -5,9 +5,9 @@ - - - + + + @@ -21,11 +21,11 @@ - - + + - + @@ -35,13 +35,13 @@ - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_combined_metrics_plan__ep_0.xml index 35d3e1ed33..0d67248318 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_combined_metrics_plan__ep_0.xml @@ -2,85 +2,85 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_joined_plan__ep_0.xml index cf1f368a88..6d31dd15e4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_joined_plan__ep_0.xml @@ -8,9 +8,9 @@ - - - + + + @@ -19,14 +19,14 @@ - - + + - + - + - - + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml index f77cd373c7..381230ff5b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml @@ -2,40 +2,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_small_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_small_combined_metrics_plan__ep_0.xml index a41f3173fe..2c6243fd7e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_small_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_small_combined_metrics_plan__ep_0.xml @@ -5,9 +5,9 @@ - - - + + + @@ -21,11 +21,11 @@ - - + + - + @@ -35,13 +35,13 @@ - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_combined_metrics_plan__ep_0.xml index 35d3e1ed33..0d67248318 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_combined_metrics_plan__ep_0.xml @@ -2,85 +2,85 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_joined_plan__ep_0.xml index cf1f368a88..6d31dd15e4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_joined_plan__ep_0.xml @@ -8,9 +8,9 @@ - - - + + + @@ -19,14 +19,14 @@ - - + + - + - + - - + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml index f77cd373c7..381230ff5b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml @@ -2,40 +2,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_small_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_small_combined_metrics_plan__ep_0.xml index a41f3173fe..2c6243fd7e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_small_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_small_combined_metrics_plan__ep_0.xml @@ -5,9 +5,9 @@ - - - + + + @@ -21,11 +21,11 @@ - - + + - + @@ -35,13 +35,13 @@ - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_combined_metrics_plan__ep_0.xml index 35d3e1ed33..0d67248318 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_combined_metrics_plan__ep_0.xml @@ -2,85 +2,85 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_joined_plan__ep_0.xml index cf1f368a88..6d31dd15e4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_joined_plan__ep_0.xml @@ -8,9 +8,9 @@ - - - + + + @@ -19,14 +19,14 @@ - - + + - + - + - - + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml index f77cd373c7..381230ff5b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml @@ -2,40 +2,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_small_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_small_combined_metrics_plan__ep_0.xml index a41f3173fe..2c6243fd7e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_small_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_small_combined_metrics_plan__ep_0.xml @@ -5,9 +5,9 @@ - - - + + + @@ -21,11 +21,11 @@ - - + + - + @@ -35,13 +35,13 @@ - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_combined_metrics_plan__ep_0.xml index 35d3e1ed33..0d67248318 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_combined_metrics_plan__ep_0.xml @@ -2,85 +2,85 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_joined_plan__ep_0.xml index cf1f368a88..6d31dd15e4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_joined_plan__ep_0.xml @@ -8,9 +8,9 @@ - - - + + + @@ -19,14 +19,14 @@ - - + + - + - + - - + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_multihop_joined_plan__ep_0.xml index f77cd373c7..381230ff5b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_multihop_joined_plan__ep_0.xml @@ -2,40 +2,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_small_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_small_combined_metrics_plan__ep_0.xml index a41f3173fe..2c6243fd7e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_small_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_small_combined_metrics_plan__ep_0.xml @@ -5,9 +5,9 @@ - - - + + + @@ -21,11 +21,11 @@ - - + + - + @@ -35,13 +35,13 @@ - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_combine_output_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_combine_output_node__plan0.sql index 395b5b7783..ede62dadf5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_combine_output_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_combine_output_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY @@ -128,93 +128,93 @@ FULL OUTER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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_3 ) subq_4 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_combine_output_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_combine_output_node__plan0_optimized.sql index d43506f88a..82d615852d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_combine_output_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_combine_output_node__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( SELECT is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 GROUP BY is_instant @@ -33,7 +33,7 @@ FULL OUTER JOIN ( is_instant , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_10 GROUP BY is_instant diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0.sql index 59667d1092..1d9350f10b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0_optimized.sql index 69b81c39cb..39785fc45b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Compute Metrics via Expressions SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -11,12 +11,12 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY listing , listing__country_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index c3bfd5547a..e138fde09b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -1,693 +1,693 @@ -- Compute Metrics via Expressions SELECT - subq_20.ds__day - , subq_20.listing__country_latest - , CAST(subq_20.bookings AS FLOAT64) / CAST(NULLIF(subq_20.views, 0) AS FLOAT64) AS bookings_per_view + subq_29.ds__day + , subq_29.listing__country_latest + , CAST(subq_29.bookings AS FLOAT64) / CAST(NULLIF(subq_29.views, 0) AS FLOAT64) AS bookings_per_view FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.ds__day, subq_19.ds__day) AS ds__day - , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) AS listing__country_latest - , MAX(subq_9.bookings) AS bookings - , MAX(subq_19.views) AS views + COALESCE(subq_18.ds__day, subq_28.ds__day) AS ds__day + , COALESCE(subq_18.listing__country_latest, subq_28.listing__country_latest) AS listing__country_latest + , MAX(subq_18.bookings) AS bookings + , MAX(subq_28.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_8.ds__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_17.ds__day + , subq_17.listing__country_latest + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.ds__day - , subq_7.listing__country_latest - , SUM(subq_7.bookings) AS bookings + subq_16.ds__day + , subq_16.listing__country_latest + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] SELECT - subq_6.ds__day - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.ds__day + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.listing AS listing - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.ds__day AS ds__day + , subq_11.listing AS listing + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] SELECT - subq_1.ds__day - , subq_1.listing - , subq_1.bookings + subq_10.ds__day + , subq_10.listing + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 GROUP BY ds__day , listing__country_latest - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_18.ds__day - , subq_18.listing__country_latest - , subq_18.views + subq_27.ds__day + , subq_27.listing__country_latest + , subq_27.views FROM ( -- Aggregate Measures SELECT - subq_17.ds__day - , subq_17.listing__country_latest - , SUM(subq_17.views) AS views + subq_26.ds__day + , subq_26.listing__country_latest + , SUM(subq_26.views) AS views FROM ( -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] SELECT - subq_16.ds__day - , subq_16.listing__country_latest - , subq_16.views + subq_25.ds__day + , subq_25.listing__country_latest + , subq_25.views FROM ( -- Join Standard Outputs SELECT - subq_12.ds__day AS ds__day - , subq_12.listing AS listing - , subq_15.country_latest AS listing__country_latest - , subq_12.views AS views + subq_21.ds__day AS ds__day + , subq_21.listing AS listing + , subq_24.country_latest AS listing__country_latest + , subq_21.views AS views FROM ( -- Pass Only Elements: ['views', 'ds__day', 'listing'] SELECT - subq_11.ds__day - , subq_11.listing - , subq_11.views + subq_20.ds__day + , subq_20.listing + , subq_20.views 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.view__ds__day - , subq_10.view__ds__week - , subq_10.view__ds__month - , subq_10.view__ds__quarter - , subq_10.view__ds__year - , subq_10.view__ds__extract_year - , subq_10.view__ds__extract_quarter - , subq_10.view__ds__extract_month - , subq_10.view__ds__extract_day - , subq_10.view__ds__extract_dow - , subq_10.view__ds__extract_doy - , subq_10.view__ds_partitioned__day - , subq_10.view__ds_partitioned__week - , subq_10.view__ds_partitioned__month - , subq_10.view__ds_partitioned__quarter - , subq_10.view__ds_partitioned__year - , subq_10.view__ds_partitioned__extract_year - , subq_10.view__ds_partitioned__extract_quarter - , subq_10.view__ds_partitioned__extract_month - , subq_10.view__ds_partitioned__extract_day - , subq_10.view__ds_partitioned__extract_dow - , subq_10.view__ds_partitioned__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.view__listing - , subq_10.view__user - , subq_10.views + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.view__ds__day + , subq_19.view__ds__week + , subq_19.view__ds__month + , subq_19.view__ds__quarter + , subq_19.view__ds__year + , subq_19.view__ds__extract_year + , subq_19.view__ds__extract_quarter + , subq_19.view__ds__extract_month + , subq_19.view__ds__extract_day + , subq_19.view__ds__extract_dow + , subq_19.view__ds__extract_doy + , subq_19.view__ds_partitioned__day + , subq_19.view__ds_partitioned__week + , subq_19.view__ds_partitioned__month + , subq_19.view__ds_partitioned__quarter + , subq_19.view__ds_partitioned__year + , subq_19.view__ds_partitioned__extract_year + , subq_19.view__ds_partitioned__extract_quarter + , subq_19.view__ds_partitioned__extract_month + , subq_19.view__ds_partitioned__extract_day + , subq_19.view__ds_partitioned__extract_dow + , subq_19.view__ds_partitioned__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.user + , subq_19.view__listing + , subq_19.view__user + , subq_19.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , DATE_TRUNC(views_source_src_28010.ds, day) AS ds__day - , DATE_TRUNC(views_source_src_28010.ds, isoweek) AS ds__week - , DATE_TRUNC(views_source_src_28010.ds, month) AS ds__month - , DATE_TRUNC(views_source_src_28010.ds, quarter) AS ds__quarter - , DATE_TRUNC(views_source_src_28010.ds, year) AS ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM views_source_src_28010.ds) = 1, 7, EXTRACT(dayofweek FROM views_source_src_28010.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM views_source_src_28010.ds) AS ds__extract_doy - , DATE_TRUNC(views_source_src_28010.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(views_source_src_28010.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(views_source_src_28010.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(views_source_src_28010.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(views_source_src_28010.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM views_source_src_28010.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM views_source_src_28010.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(views_source_src_28010.ds, day) AS view__ds__day - , DATE_TRUNC(views_source_src_28010.ds, isoweek) AS view__ds__week - , DATE_TRUNC(views_source_src_28010.ds, month) AS view__ds__month - , DATE_TRUNC(views_source_src_28010.ds, quarter) AS view__ds__quarter - , DATE_TRUNC(views_source_src_28010.ds, year) AS view__ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS view__ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS view__ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS view__ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS view__ds__extract_day - , IF(EXTRACT(dayofweek FROM views_source_src_28010.ds) = 1, 7, EXTRACT(dayofweek FROM views_source_src_28010.ds) - 1) AS view__ds__extract_dow - , EXTRACT(dayofyear FROM views_source_src_28010.ds) AS view__ds__extract_doy - , DATE_TRUNC(views_source_src_28010.ds_partitioned, day) AS view__ds_partitioned__day - , DATE_TRUNC(views_source_src_28010.ds_partitioned, isoweek) AS view__ds_partitioned__week - , DATE_TRUNC(views_source_src_28010.ds_partitioned, month) AS view__ds_partitioned__month - , DATE_TRUNC(views_source_src_28010.ds_partitioned, quarter) AS view__ds_partitioned__quarter - , DATE_TRUNC(views_source_src_28010.ds_partitioned, year) AS view__ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM views_source_src_28010.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM views_source_src_28010.ds_partitioned) - 1) AS view__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_doy - , views_source_src_28010.listing_id AS listing - , views_source_src_28010.user_id AS user - , views_source_src_28010.listing_id AS view__listing - , views_source_src_28010.user_id AS view__user - FROM ***************************.fct_views views_source_src_28010 - ) subq_10 - ) subq_11 - ) subq_12 + , DATE_TRUNC(views_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(views_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(views_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(views_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(views_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM views_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM views_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM views_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC(views_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(views_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(views_source_src_28000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM views_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM views_source_src_28000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC(views_source_src_28000.ds, day) AS view__ds__day + , DATE_TRUNC(views_source_src_28000.ds, isoweek) AS view__ds__week + , DATE_TRUNC(views_source_src_28000.ds, month) AS view__ds__month + , DATE_TRUNC(views_source_src_28000.ds, quarter) AS view__ds__quarter + , DATE_TRUNC(views_source_src_28000.ds, year) AS view__ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS view__ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS view__ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS view__ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS view__ds__extract_day + , IF(EXTRACT(dayofweek FROM views_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM views_source_src_28000.ds) - 1) AS view__ds__extract_dow + , EXTRACT(dayofyear FROM views_source_src_28000.ds) AS view__ds__extract_doy + , DATE_TRUNC(views_source_src_28000.ds_partitioned, day) AS view__ds_partitioned__day + , DATE_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS view__ds_partitioned__week + , DATE_TRUNC(views_source_src_28000.ds_partitioned, month) AS view__ds_partitioned__month + , DATE_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS view__ds_partitioned__quarter + , DATE_TRUNC(views_source_src_28000.ds_partitioned, year) AS view__ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM views_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM views_source_src_28000.ds_partitioned) - 1) AS view__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_doy + , views_source_src_28000.listing_id AS listing + , views_source_src_28000.user_id AS user + , views_source_src_28000.listing_id AS view__listing + , views_source_src_28000.user_id AS view__user + FROM ***************************.fct_views views_source_src_28000 + ) subq_19 + ) subq_20 + ) subq_21 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_14.listing - , subq_14.country_latest + subq_23.listing + , subq_23.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_13.ds__day - , subq_13.ds__week - , subq_13.ds__month - , subq_13.ds__quarter - , subq_13.ds__year - , subq_13.ds__extract_year - , subq_13.ds__extract_quarter - , subq_13.ds__extract_month - , subq_13.ds__extract_day - , subq_13.ds__extract_dow - , subq_13.ds__extract_doy - , subq_13.created_at__day - , subq_13.created_at__week - , subq_13.created_at__month - , subq_13.created_at__quarter - , subq_13.created_at__year - , subq_13.created_at__extract_year - , subq_13.created_at__extract_quarter - , subq_13.created_at__extract_month - , subq_13.created_at__extract_day - , subq_13.created_at__extract_dow - , subq_13.created_at__extract_doy - , subq_13.listing__ds__day - , subq_13.listing__ds__week - , subq_13.listing__ds__month - , subq_13.listing__ds__quarter - , subq_13.listing__ds__year - , subq_13.listing__ds__extract_year - , subq_13.listing__ds__extract_quarter - , subq_13.listing__ds__extract_month - , subq_13.listing__ds__extract_day - , subq_13.listing__ds__extract_dow - , subq_13.listing__ds__extract_doy - , subq_13.listing__created_at__day - , subq_13.listing__created_at__week - , subq_13.listing__created_at__month - , subq_13.listing__created_at__quarter - , subq_13.listing__created_at__year - , subq_13.listing__created_at__extract_year - , subq_13.listing__created_at__extract_quarter - , subq_13.listing__created_at__extract_month - , subq_13.listing__created_at__extract_day - , subq_13.listing__created_at__extract_dow - , subq_13.listing__created_at__extract_doy - , subq_13.ds__day AS metric_time__day - , subq_13.ds__week AS metric_time__week - , subq_13.ds__month AS metric_time__month - , subq_13.ds__quarter AS metric_time__quarter - , subq_13.ds__year AS metric_time__year - , subq_13.ds__extract_year AS metric_time__extract_year - , subq_13.ds__extract_quarter AS metric_time__extract_quarter - , subq_13.ds__extract_month AS metric_time__extract_month - , subq_13.ds__extract_day AS metric_time__extract_day - , subq_13.ds__extract_dow AS metric_time__extract_dow - , subq_13.ds__extract_doy AS metric_time__extract_doy - , subq_13.listing - , subq_13.user - , subq_13.listing__user - , subq_13.country_latest - , subq_13.is_lux_latest - , subq_13.capacity_latest - , subq_13.listing__country_latest - , subq_13.listing__is_lux_latest - , subq_13.listing__capacity_latest - , subq_13.listings - , subq_13.largest_listing - , subq_13.smallest_listing + 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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_13 - ) subq_14 - ) subq_15 + , 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_22 + ) subq_23 + ) subq_24 ON - subq_12.listing = subq_15.listing - ) subq_16 - ) subq_17 + subq_21.listing = subq_24.listing + ) subq_25 + ) subq_26 GROUP BY ds__day , listing__country_latest - ) subq_18 - ) subq_19 + ) subq_27 + ) subq_28 ON ( - subq_9.listing__country_latest = subq_19.listing__country_latest + subq_18.listing__country_latest = subq_28.listing__country_latest ) AND ( - subq_9.ds__day = subq_19.ds__day + subq_18.ds__day = subq_28.ds__day ) GROUP BY ds__day , listing__country_latest -) subq_20 +) subq_29 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 4075d1f5ce..e9b09f77b3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -6,19 +6,19 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest - , MAX(subq_30.bookings) AS bookings - , MAX(subq_40.views) AS views + COALESCE(subq_39.ds__day, subq_49.ds__day) AS ds__day + , COALESCE(subq_39.listing__country_latest, subq_49.listing__country_latest) AS listing__country_latest + , MAX(subq_39.bookings) AS bookings + , MAX(subq_49.views) AS views FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_23.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + subq_32.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_32.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -27,25 +27,25 @@ FROM ( DATE_TRUNC(ds, day) AS ds__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_23.listing = listings_latest_src_28005.listing_id + subq_32.listing = listings_latest_src_28000.listing_id GROUP BY ds__day , listing__country_latest - ) subq_30 + ) subq_39 FULL OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_33.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_33.views) AS views + subq_42.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_42.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' @@ -54,23 +54,23 @@ FROM ( DATE_TRUNC(ds, day) AS ds__day , listing_id AS listing , 1 AS views - FROM ***************************.fct_views views_source_src_28010 - ) subq_33 + FROM ***************************.fct_views views_source_src_28000 + ) subq_42 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_33.listing = listings_latest_src_28005.listing_id + subq_42.listing = listings_latest_src_28000.listing_id GROUP BY ds__day , listing__country_latest - ) subq_40 + ) subq_49 ON ( - subq_30.listing__country_latest = subq_40.listing__country_latest + subq_39.listing__country_latest = subq_49.listing__country_latest ) AND ( - subq_30.ds__day = subq_40.ds__day + subq_39.ds__day = subq_49.ds__day ) GROUP BY ds__day , listing__country_latest -) subq_41 +) subq_50 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 691359df82..53c5458c05 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -28,93 +28,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql index e61134a4ec..2d92a0b0ea 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Aggregate Measures SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings , COUNT(DISTINCT subq_7.bookers) AS bookers FROM ( @@ -18,12 +18,12 @@ FROM ( listing_id AS listing , 1 AS bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY listing , listing__country_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0.sql index 95a8a594e8..bb6a7cc7c8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0_optimized.sql index 85d8832dfe..d646b7402f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0_optimized.sql @@ -7,14 +7,14 @@ FROM ( -- Join Standard Outputs -- Aggregate Measures SELECT - bookings_source_src_28001.listing_id AS listing - , listings_latest_src_28005.country AS listing__country_latest - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.listing_id AS listing + , listings_latest_src_28000.country AS listing__country_latest + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY listing , listing__country_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0.sql index a0e9d75a3b..f35d50cc54 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0_optimized.sql index 75eef26f7e..9c5e3ef726 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0_optimized.sql @@ -6,5 +6,5 @@ SELECT DATE_TRUNC(ds, day) AS ds__day , DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC(ds, day) BETWEEN '2020-01-01' AND '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0.sql index 1450c75977..4da4d7d82c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -190,32 +190,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_28009.ds, day) AS ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC(users_latest_src_28009.ds, day) AS user__ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS user__ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS user__ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS user__ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0_optimized.sql index 8cc8a2b867..c4e57d3c86 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,13 +5,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.country AS listing__country_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.country AS listing__country_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql index 8fdb02c3a8..ebe3631edd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_28009.ds, day) AS ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC(users_latest_src_28009.ds, day) AS user__ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS user__ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS user__ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS user__ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql index 8be14ae725..4365193bed 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY listing__is_lux_latest , user__home_state_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_node__plan0.sql index 5bb3c3d1a9..b5ff0578b8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_node__plan0.sql @@ -6,91 +6,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_node__plan0_optimized.sql index bfbf5ff951..554ce484fb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_node__plan0_optimized.sql @@ -2,4 +2,4 @@ -- Pass Only Elements: ['bookings',] SELECT 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0.sql index ecc9bba0c8..c6f25b8c6b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0_optimized.sql index 6f43403722..2ab56070e3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0_optimized.sql @@ -8,6 +8,6 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_3 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index 2566084583..52483571be 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index 605c639d2c..de1c51339b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY metric_time__day , listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0.sql index c9b4153e21..4d85900d84 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index 2174faa702..33bf45f967 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY metric_time__day , listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0.sql index 9bf9f87b20..b890725bb3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 0dc2b15fa5..22fd39eb0b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY metric_time__day , listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_aggregation_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_aggregation_node__plan0.sql index d37595fcab..64a83506ab 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_aggregation_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_aggregation_node__plan0.sql @@ -16,92 +16,92 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_aggregation_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_aggregation_node__plan0_optimized.sql index 64fc2826b9..6e5528a6c9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_aggregation_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_aggregation_node__plan0_optimized.sql @@ -6,4 +6,4 @@ SELECT , SUM(CASE WHEN is_instant THEN 1 ELSE 0 END) AS instant_bookings , COUNT(DISTINCT guest_id) AS bookers , AVG(booking_value) AS average_booking_value -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0.sql index 8538ea9e3f..a184642565 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0.sql @@ -14,93 +14,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -112,62 +112,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON @@ -181,62 +181,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0_optimized.sql index b9cecc48d8..7d9c669f54 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -18,7 +18,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_9 ON subq_7.listing = subq_9.listing @@ -28,7 +28,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_11 ON subq_7.listing = subq_11.listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0.sql index c609e114ee..33b3ebed38 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0.sql @@ -26,93 +26,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0_optimized.sql index 28767fcd6f..e755ce8680 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( DATE_TRUNC(ds, day) AS ds__day , is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 GROUP BY ds__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0.sql index 6d9849d14f..2baea3c2d6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -110,62 +110,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0_optimized.sql index e03ffcce64..a1cd7ac335 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_5.listing = listings_latest_src_28005.listing_id + subq_5.listing = listings_latest_src_28000.listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0.sql index 69189e43bb..c614493864 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0.sql @@ -2,90 +2,90 @@ SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0_optimized.sql index 2778fb000b..641da95a40 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0_optimized.sql @@ -88,4 +88,4 @@ SELECT , listing_id AS booking__listing , guest_id AS booking__guest , host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_combine_output_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_combine_output_node__plan0.sql index f350d5ead8..b66a332135 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_combine_output_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_combine_output_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY @@ -128,93 +128,93 @@ FULL OUTER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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_3 ) subq_4 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_combine_output_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_combine_output_node__plan0_optimized.sql index a8375510d7..ad81788114 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_combine_output_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_combine_output_node__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( SELECT is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 GROUP BY is_instant @@ -33,7 +33,7 @@ FULL OUTER JOIN ( is_instant , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_10 GROUP BY is_instant diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0.sql index 4c6fec948c..b6d83b8cf4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0_optimized.sql index cf47afc6bf..5ebe7177e8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Compute Metrics via Expressions SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -11,12 +11,12 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY subq_7.listing - , listings_latest_src_28005.country + , listings_latest_src_28000.country diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index ae05dce9db..dcb28780fe 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -1,693 +1,693 @@ -- Compute Metrics via Expressions SELECT - subq_20.ds__day - , subq_20.listing__country_latest - , CAST(subq_20.bookings AS DOUBLE) / CAST(NULLIF(subq_20.views, 0) AS DOUBLE) AS bookings_per_view + subq_29.ds__day + , subq_29.listing__country_latest + , CAST(subq_29.bookings AS DOUBLE) / CAST(NULLIF(subq_29.views, 0) AS DOUBLE) AS bookings_per_view FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.ds__day, subq_19.ds__day) AS ds__day - , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) AS listing__country_latest - , MAX(subq_9.bookings) AS bookings - , MAX(subq_19.views) AS views + COALESCE(subq_18.ds__day, subq_28.ds__day) AS ds__day + , COALESCE(subq_18.listing__country_latest, subq_28.listing__country_latest) AS listing__country_latest + , MAX(subq_18.bookings) AS bookings + , MAX(subq_28.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_8.ds__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_17.ds__day + , subq_17.listing__country_latest + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.ds__day - , subq_7.listing__country_latest - , SUM(subq_7.bookings) AS bookings + subq_16.ds__day + , subq_16.listing__country_latest + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] SELECT - subq_6.ds__day - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.ds__day + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.listing AS listing - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.ds__day AS ds__day + , subq_11.listing AS listing + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] SELECT - subq_1.ds__day - , subq_1.listing - , subq_1.bookings + subq_10.ds__day + , subq_10.listing + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 GROUP BY - subq_7.ds__day - , subq_7.listing__country_latest - ) subq_8 - ) subq_9 + subq_16.ds__day + , subq_16.listing__country_latest + ) subq_17 + ) subq_18 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_18.ds__day - , subq_18.listing__country_latest - , subq_18.views + subq_27.ds__day + , subq_27.listing__country_latest + , subq_27.views FROM ( -- Aggregate Measures SELECT - subq_17.ds__day - , subq_17.listing__country_latest - , SUM(subq_17.views) AS views + subq_26.ds__day + , subq_26.listing__country_latest + , SUM(subq_26.views) AS views FROM ( -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] SELECT - subq_16.ds__day - , subq_16.listing__country_latest - , subq_16.views + subq_25.ds__day + , subq_25.listing__country_latest + , subq_25.views FROM ( -- Join Standard Outputs SELECT - subq_12.ds__day AS ds__day - , subq_12.listing AS listing - , subq_15.country_latest AS listing__country_latest - , subq_12.views AS views + subq_21.ds__day AS ds__day + , subq_21.listing AS listing + , subq_24.country_latest AS listing__country_latest + , subq_21.views AS views FROM ( -- Pass Only Elements: ['views', 'ds__day', 'listing'] SELECT - subq_11.ds__day - , subq_11.listing - , subq_11.views + subq_20.ds__day + , subq_20.listing + , subq_20.views 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.view__ds__day - , subq_10.view__ds__week - , subq_10.view__ds__month - , subq_10.view__ds__quarter - , subq_10.view__ds__year - , subq_10.view__ds__extract_year - , subq_10.view__ds__extract_quarter - , subq_10.view__ds__extract_month - , subq_10.view__ds__extract_day - , subq_10.view__ds__extract_dow - , subq_10.view__ds__extract_doy - , subq_10.view__ds_partitioned__day - , subq_10.view__ds_partitioned__week - , subq_10.view__ds_partitioned__month - , subq_10.view__ds_partitioned__quarter - , subq_10.view__ds_partitioned__year - , subq_10.view__ds_partitioned__extract_year - , subq_10.view__ds_partitioned__extract_quarter - , subq_10.view__ds_partitioned__extract_month - , subq_10.view__ds_partitioned__extract_day - , subq_10.view__ds_partitioned__extract_dow - , subq_10.view__ds_partitioned__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.view__listing - , subq_10.view__user - , subq_10.views + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.view__ds__day + , subq_19.view__ds__week + , subq_19.view__ds__month + , subq_19.view__ds__quarter + , subq_19.view__ds__year + , subq_19.view__ds__extract_year + , subq_19.view__ds__extract_quarter + , subq_19.view__ds__extract_month + , subq_19.view__ds__extract_day + , subq_19.view__ds__extract_dow + , subq_19.view__ds__extract_doy + , subq_19.view__ds_partitioned__day + , subq_19.view__ds_partitioned__week + , subq_19.view__ds_partitioned__month + , subq_19.view__ds_partitioned__quarter + , subq_19.view__ds_partitioned__year + , subq_19.view__ds_partitioned__extract_year + , subq_19.view__ds_partitioned__extract_quarter + , subq_19.view__ds_partitioned__extract_month + , subq_19.view__ds_partitioned__extract_day + , subq_19.view__ds_partitioned__extract_dow + , subq_19.view__ds_partitioned__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.user + , subq_19.view__listing + , subq_19.view__user + , subq_19.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , DATE_TRUNC('day', views_source_src_28010.ds) AS ds__day - , DATE_TRUNC('week', views_source_src_28010.ds) AS ds__week - , DATE_TRUNC('month', views_source_src_28010.ds) AS ds__month - , DATE_TRUNC('quarter', views_source_src_28010.ds) AS ds__quarter - , DATE_TRUNC('year', views_source_src_28010.ds) AS ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_28010.ds) AS ds__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds) AS ds__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', views_source_src_28010.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', views_source_src_28010.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_28010.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_28010.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds) AS view__ds__day - , DATE_TRUNC('week', views_source_src_28010.ds) AS view__ds__week - , DATE_TRUNC('month', views_source_src_28010.ds) AS view__ds__month - , DATE_TRUNC('quarter', views_source_src_28010.ds) AS view__ds__quarter - , DATE_TRUNC('year', views_source_src_28010.ds) AS view__ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS view__ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS view__ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS view__ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS view__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_28010.ds) AS view__ds__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds) AS view__ds__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__day - , DATE_TRUNC('week', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__week - , DATE_TRUNC('month', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_doy - , views_source_src_28010.listing_id AS listing - , views_source_src_28010.user_id AS user - , views_source_src_28010.listing_id AS view__listing - , views_source_src_28010.user_id AS view__user - FROM ***************************.fct_views views_source_src_28010 - ) subq_10 - ) subq_11 - ) subq_12 + , DATE_TRUNC('day', views_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', views_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', views_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', views_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', views_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', views_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', views_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds) AS view__ds__day + , DATE_TRUNC('week', views_source_src_28000.ds) AS view__ds__week + , DATE_TRUNC('month', views_source_src_28000.ds) AS view__ds__month + , DATE_TRUNC('quarter', views_source_src_28000.ds) AS view__ds__quarter + , DATE_TRUNC('year', views_source_src_28000.ds) AS view__ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS view__ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS view__ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS view__ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS view__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_28000.ds) AS view__ds__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds) AS view__ds__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__day + , DATE_TRUNC('week', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__week + , DATE_TRUNC('month', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_doy + , views_source_src_28000.listing_id AS listing + , views_source_src_28000.user_id AS user + , views_source_src_28000.listing_id AS view__listing + , views_source_src_28000.user_id AS view__user + FROM ***************************.fct_views views_source_src_28000 + ) subq_19 + ) subq_20 + ) subq_21 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_14.listing - , subq_14.country_latest + subq_23.listing + , subq_23.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_13.ds__day - , subq_13.ds__week - , subq_13.ds__month - , subq_13.ds__quarter - , subq_13.ds__year - , subq_13.ds__extract_year - , subq_13.ds__extract_quarter - , subq_13.ds__extract_month - , subq_13.ds__extract_day - , subq_13.ds__extract_dow - , subq_13.ds__extract_doy - , subq_13.created_at__day - , subq_13.created_at__week - , subq_13.created_at__month - , subq_13.created_at__quarter - , subq_13.created_at__year - , subq_13.created_at__extract_year - , subq_13.created_at__extract_quarter - , subq_13.created_at__extract_month - , subq_13.created_at__extract_day - , subq_13.created_at__extract_dow - , subq_13.created_at__extract_doy - , subq_13.listing__ds__day - , subq_13.listing__ds__week - , subq_13.listing__ds__month - , subq_13.listing__ds__quarter - , subq_13.listing__ds__year - , subq_13.listing__ds__extract_year - , subq_13.listing__ds__extract_quarter - , subq_13.listing__ds__extract_month - , subq_13.listing__ds__extract_day - , subq_13.listing__ds__extract_dow - , subq_13.listing__ds__extract_doy - , subq_13.listing__created_at__day - , subq_13.listing__created_at__week - , subq_13.listing__created_at__month - , subq_13.listing__created_at__quarter - , subq_13.listing__created_at__year - , subq_13.listing__created_at__extract_year - , subq_13.listing__created_at__extract_quarter - , subq_13.listing__created_at__extract_month - , subq_13.listing__created_at__extract_day - , subq_13.listing__created_at__extract_dow - , subq_13.listing__created_at__extract_doy - , subq_13.ds__day AS metric_time__day - , subq_13.ds__week AS metric_time__week - , subq_13.ds__month AS metric_time__month - , subq_13.ds__quarter AS metric_time__quarter - , subq_13.ds__year AS metric_time__year - , subq_13.ds__extract_year AS metric_time__extract_year - , subq_13.ds__extract_quarter AS metric_time__extract_quarter - , subq_13.ds__extract_month AS metric_time__extract_month - , subq_13.ds__extract_day AS metric_time__extract_day - , subq_13.ds__extract_dow AS metric_time__extract_dow - , subq_13.ds__extract_doy AS metric_time__extract_doy - , subq_13.listing - , subq_13.user - , subq_13.listing__user - , subq_13.country_latest - , subq_13.is_lux_latest - , subq_13.capacity_latest - , subq_13.listing__country_latest - , subq_13.listing__is_lux_latest - , subq_13.listing__capacity_latest - , subq_13.listings - , subq_13.largest_listing - , subq_13.smallest_listing + 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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_13 - ) subq_14 - ) subq_15 + , 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_22 + ) subq_23 + ) subq_24 ON - subq_12.listing = subq_15.listing - ) subq_16 - ) subq_17 + subq_21.listing = subq_24.listing + ) subq_25 + ) subq_26 GROUP BY - subq_17.ds__day - , subq_17.listing__country_latest - ) subq_18 - ) subq_19 + subq_26.ds__day + , subq_26.listing__country_latest + ) subq_27 + ) subq_28 ON ( - subq_9.listing__country_latest = subq_19.listing__country_latest + subq_18.listing__country_latest = subq_28.listing__country_latest ) AND ( - subq_9.ds__day = subq_19.ds__day + subq_18.ds__day = subq_28.ds__day ) GROUP BY - COALESCE(subq_9.ds__day, subq_19.ds__day) - , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) -) subq_20 + COALESCE(subq_18.ds__day, subq_28.ds__day) + , COALESCE(subq_18.listing__country_latest, subq_28.listing__country_latest) +) subq_29 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 5b65e65d85..75a09cbc63 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -6,19 +6,19 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest - , MAX(subq_30.bookings) AS bookings - , MAX(subq_40.views) AS views + COALESCE(subq_39.ds__day, subq_49.ds__day) AS ds__day + , COALESCE(subq_39.listing__country_latest, subq_49.listing__country_latest) AS listing__country_latest + , MAX(subq_39.bookings) AS bookings + , MAX(subq_49.views) AS views FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_23.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + subq_32.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_32.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -27,25 +27,25 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_23.listing = listings_latest_src_28005.listing_id + subq_32.listing = listings_latest_src_28000.listing_id GROUP BY - subq_23.ds__day - , listings_latest_src_28005.country - ) subq_30 + subq_32.ds__day + , listings_latest_src_28000.country + ) subq_39 FULL OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_33.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_33.views) AS views + subq_42.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_42.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' @@ -54,23 +54,23 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views - FROM ***************************.fct_views views_source_src_28010 - ) subq_33 + FROM ***************************.fct_views views_source_src_28000 + ) subq_42 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_33.listing = listings_latest_src_28005.listing_id + subq_42.listing = listings_latest_src_28000.listing_id GROUP BY - subq_33.ds__day - , listings_latest_src_28005.country - ) subq_40 + subq_42.ds__day + , listings_latest_src_28000.country + ) subq_49 ON ( - subq_30.listing__country_latest = subq_40.listing__country_latest + subq_39.listing__country_latest = subq_49.listing__country_latest ) AND ( - subq_30.ds__day = subq_40.ds__day + subq_39.ds__day = subq_49.ds__day ) GROUP BY - COALESCE(subq_30.ds__day, subq_40.ds__day) - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) -) subq_41 + COALESCE(subq_39.ds__day, subq_49.ds__day) + , COALESCE(subq_39.listing__country_latest, subq_49.listing__country_latest) +) subq_50 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index c7ad99ba70..f5b5ee6cc2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -28,93 +28,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql index 7c57c360fb..c943b1a8d9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Aggregate Measures SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings , COUNT(DISTINCT subq_7.bookers) AS bookers FROM ( @@ -18,13 +18,13 @@ FROM ( listing_id AS listing , 1 AS bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY subq_7.listing - , listings_latest_src_28005.country + , listings_latest_src_28000.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0.sql index e4ff7804c2..e0efb20972 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0_optimized.sql index 3bda7562bf..65e701e3dd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0_optimized.sql @@ -7,15 +7,15 @@ FROM ( -- Join Standard Outputs -- Aggregate Measures SELECT - bookings_source_src_28001.listing_id AS listing - , listings_latest_src_28005.country AS listing__country_latest - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.listing_id AS listing + , listings_latest_src_28000.country AS listing__country_latest + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY - bookings_source_src_28001.listing_id - , listings_latest_src_28005.country + bookings_source_src_28000.listing_id + , listings_latest_src_28000.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0.sql index a9d000576c..a767f9cc0b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0_optimized.sql index db53f26587..d0d15f6943 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0_optimized.sql @@ -6,5 +6,5 @@ SELECT DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0.sql index 96f3e16f3c..1d8a2bddf2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -190,32 +190,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0_optimized.sql index 8cc8a2b867..c4e57d3c86 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,13 +5,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.country AS listing__country_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.country AS listing__country_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql index 5fd13a23f2..d66932d7d4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql index bee3a232b6..96c5d5bb3a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY - listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_node__plan0.sql index 5f826772a6..343ccdb7e8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_node__plan0.sql @@ -6,91 +6,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_node__plan0_optimized.sql index bfbf5ff951..554ce484fb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_node__plan0_optimized.sql @@ -2,4 +2,4 @@ -- Pass Only Elements: ['bookings',] SELECT 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0.sql index 08de4a04d0..a39a7e7609 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0_optimized.sql index 755a4d39e2..5ee87ba25f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0_optimized.sql @@ -8,6 +8,6 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_3 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index 152b0e013c..eec56d28b8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index d5d4ba056e..6054b232dc 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0.sql index 9d60cb466a..278352a1b4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index cb1797bad8..61bc9299ec 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0.sql index 784e5f265a..84ae7ad473 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 695cf9c062..e4f47734b0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_aggregation_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_aggregation_node__plan0.sql index 7ed2fad1d8..15f15c236e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_aggregation_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_aggregation_node__plan0.sql @@ -16,92 +16,92 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_aggregation_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_aggregation_node__plan0_optimized.sql index 64fc2826b9..6e5528a6c9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_aggregation_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_aggregation_node__plan0_optimized.sql @@ -6,4 +6,4 @@ SELECT , SUM(CASE WHEN is_instant THEN 1 ELSE 0 END) AS instant_bookings , COUNT(DISTINCT guest_id) AS bookers , AVG(booking_value) AS average_booking_value -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0.sql index 570d1f67eb..27a7f61bce 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0.sql @@ -14,93 +14,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -112,62 +112,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON @@ -181,62 +181,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0_optimized.sql index b9cecc48d8..7d9c669f54 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -18,7 +18,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_9 ON subq_7.listing = subq_9.listing @@ -28,7 +28,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_11 ON subq_7.listing = subq_11.listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0.sql index 73a9be7514..6c7a1e644c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0.sql @@ -26,93 +26,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0_optimized.sql index fd8a1ff597..bcebfe9d5f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 GROUP BY ds__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0.sql index 67e5f3fe2d..05e59e291e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -110,62 +110,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0_optimized.sql index e03ffcce64..a1cd7ac335 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_5.listing = listings_latest_src_28005.listing_id + subq_5.listing = listings_latest_src_28000.listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0.sql index 00c7139994..da33eea744 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0.sql @@ -2,90 +2,90 @@ SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0_optimized.sql index 32dc9ad747..5987daa5e3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0_optimized.sql @@ -88,4 +88,4 @@ SELECT , listing_id AS booking__listing , guest_id AS booking__guest , host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_combine_output_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_combine_output_node__plan0.sql index a8375b02dd..a8d97dae7f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_combine_output_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_combine_output_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY @@ -128,93 +128,93 @@ FULL OUTER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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_3 ) subq_4 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_combine_output_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_combine_output_node__plan0_optimized.sql index a8375510d7..ad81788114 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_combine_output_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_combine_output_node__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( SELECT is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 GROUP BY is_instant @@ -33,7 +33,7 @@ FULL OUTER JOIN ( is_instant , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_10 GROUP BY is_instant diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0.sql index 760f45c973..08fdfa6034 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0_optimized.sql index cf47afc6bf..5ebe7177e8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Compute Metrics via Expressions SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -11,12 +11,12 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY subq_7.listing - , listings_latest_src_28005.country + , listings_latest_src_28000.country diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 0b73a89b54..385d922587 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -1,693 +1,693 @@ -- Compute Metrics via Expressions SELECT - subq_20.ds__day - , subq_20.listing__country_latest - , CAST(subq_20.bookings AS DOUBLE) / CAST(NULLIF(subq_20.views, 0) AS DOUBLE) AS bookings_per_view + subq_29.ds__day + , subq_29.listing__country_latest + , CAST(subq_29.bookings AS DOUBLE) / CAST(NULLIF(subq_29.views, 0) AS DOUBLE) AS bookings_per_view FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.ds__day, subq_19.ds__day) AS ds__day - , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) AS listing__country_latest - , MAX(subq_9.bookings) AS bookings - , MAX(subq_19.views) AS views + COALESCE(subq_18.ds__day, subq_28.ds__day) AS ds__day + , COALESCE(subq_18.listing__country_latest, subq_28.listing__country_latest) AS listing__country_latest + , MAX(subq_18.bookings) AS bookings + , MAX(subq_28.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_8.ds__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_17.ds__day + , subq_17.listing__country_latest + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.ds__day - , subq_7.listing__country_latest - , SUM(subq_7.bookings) AS bookings + subq_16.ds__day + , subq_16.listing__country_latest + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] SELECT - subq_6.ds__day - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.ds__day + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.listing AS listing - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.ds__day AS ds__day + , subq_11.listing AS listing + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] SELECT - subq_1.ds__day - , subq_1.listing - , subq_1.bookings + subq_10.ds__day + , subq_10.listing + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 GROUP BY - subq_7.ds__day - , subq_7.listing__country_latest - ) subq_8 - ) subq_9 + subq_16.ds__day + , subq_16.listing__country_latest + ) subq_17 + ) subq_18 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_18.ds__day - , subq_18.listing__country_latest - , subq_18.views + subq_27.ds__day + , subq_27.listing__country_latest + , subq_27.views FROM ( -- Aggregate Measures SELECT - subq_17.ds__day - , subq_17.listing__country_latest - , SUM(subq_17.views) AS views + subq_26.ds__day + , subq_26.listing__country_latest + , SUM(subq_26.views) AS views FROM ( -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] SELECT - subq_16.ds__day - , subq_16.listing__country_latest - , subq_16.views + subq_25.ds__day + , subq_25.listing__country_latest + , subq_25.views FROM ( -- Join Standard Outputs SELECT - subq_12.ds__day AS ds__day - , subq_12.listing AS listing - , subq_15.country_latest AS listing__country_latest - , subq_12.views AS views + subq_21.ds__day AS ds__day + , subq_21.listing AS listing + , subq_24.country_latest AS listing__country_latest + , subq_21.views AS views FROM ( -- Pass Only Elements: ['views', 'ds__day', 'listing'] SELECT - subq_11.ds__day - , subq_11.listing - , subq_11.views + subq_20.ds__day + , subq_20.listing + , subq_20.views 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.view__ds__day - , subq_10.view__ds__week - , subq_10.view__ds__month - , subq_10.view__ds__quarter - , subq_10.view__ds__year - , subq_10.view__ds__extract_year - , subq_10.view__ds__extract_quarter - , subq_10.view__ds__extract_month - , subq_10.view__ds__extract_day - , subq_10.view__ds__extract_dow - , subq_10.view__ds__extract_doy - , subq_10.view__ds_partitioned__day - , subq_10.view__ds_partitioned__week - , subq_10.view__ds_partitioned__month - , subq_10.view__ds_partitioned__quarter - , subq_10.view__ds_partitioned__year - , subq_10.view__ds_partitioned__extract_year - , subq_10.view__ds_partitioned__extract_quarter - , subq_10.view__ds_partitioned__extract_month - , subq_10.view__ds_partitioned__extract_day - , subq_10.view__ds_partitioned__extract_dow - , subq_10.view__ds_partitioned__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.view__listing - , subq_10.view__user - , subq_10.views + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.view__ds__day + , subq_19.view__ds__week + , subq_19.view__ds__month + , subq_19.view__ds__quarter + , subq_19.view__ds__year + , subq_19.view__ds__extract_year + , subq_19.view__ds__extract_quarter + , subq_19.view__ds__extract_month + , subq_19.view__ds__extract_day + , subq_19.view__ds__extract_dow + , subq_19.view__ds__extract_doy + , subq_19.view__ds_partitioned__day + , subq_19.view__ds_partitioned__week + , subq_19.view__ds_partitioned__month + , subq_19.view__ds_partitioned__quarter + , subq_19.view__ds_partitioned__year + , subq_19.view__ds_partitioned__extract_year + , subq_19.view__ds_partitioned__extract_quarter + , subq_19.view__ds_partitioned__extract_month + , subq_19.view__ds_partitioned__extract_day + , subq_19.view__ds_partitioned__extract_dow + , subq_19.view__ds_partitioned__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.user + , subq_19.view__listing + , subq_19.view__user + , subq_19.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , DATE_TRUNC('day', views_source_src_28010.ds) AS ds__day - , DATE_TRUNC('week', views_source_src_28010.ds) AS ds__week - , DATE_TRUNC('month', views_source_src_28010.ds) AS ds__month - , DATE_TRUNC('quarter', views_source_src_28010.ds) AS ds__quarter - , DATE_TRUNC('year', views_source_src_28010.ds) AS ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS ds__extract_day - , EXTRACT(isodow FROM views_source_src_28010.ds) AS ds__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds) AS ds__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', views_source_src_28010.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', views_source_src_28010.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_28010.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_28010.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds) AS view__ds__day - , DATE_TRUNC('week', views_source_src_28010.ds) AS view__ds__week - , DATE_TRUNC('month', views_source_src_28010.ds) AS view__ds__month - , DATE_TRUNC('quarter', views_source_src_28010.ds) AS view__ds__quarter - , DATE_TRUNC('year', views_source_src_28010.ds) AS view__ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS view__ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS view__ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS view__ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS view__ds__extract_day - , EXTRACT(isodow FROM views_source_src_28010.ds) AS view__ds__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds) AS view__ds__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__day - , DATE_TRUNC('week', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__week - , DATE_TRUNC('month', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_day - , EXTRACT(isodow FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_doy - , views_source_src_28010.listing_id AS listing - , views_source_src_28010.user_id AS user - , views_source_src_28010.listing_id AS view__listing - , views_source_src_28010.user_id AS view__user - FROM ***************************.fct_views views_source_src_28010 - ) subq_10 - ) subq_11 - ) subq_12 + , DATE_TRUNC('day', views_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', views_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', views_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', views_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', views_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM views_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', views_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', views_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds) AS view__ds__day + , DATE_TRUNC('week', views_source_src_28000.ds) AS view__ds__week + , DATE_TRUNC('month', views_source_src_28000.ds) AS view__ds__month + , DATE_TRUNC('quarter', views_source_src_28000.ds) AS view__ds__quarter + , DATE_TRUNC('year', views_source_src_28000.ds) AS view__ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS view__ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS view__ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS view__ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS view__ds__extract_day + , EXTRACT(isodow FROM views_source_src_28000.ds) AS view__ds__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds) AS view__ds__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__day + , DATE_TRUNC('week', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__week + , DATE_TRUNC('month', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_day + , EXTRACT(isodow FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_doy + , views_source_src_28000.listing_id AS listing + , views_source_src_28000.user_id AS user + , views_source_src_28000.listing_id AS view__listing + , views_source_src_28000.user_id AS view__user + FROM ***************************.fct_views views_source_src_28000 + ) subq_19 + ) subq_20 + ) subq_21 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_14.listing - , subq_14.country_latest + subq_23.listing + , subq_23.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_13.ds__day - , subq_13.ds__week - , subq_13.ds__month - , subq_13.ds__quarter - , subq_13.ds__year - , subq_13.ds__extract_year - , subq_13.ds__extract_quarter - , subq_13.ds__extract_month - , subq_13.ds__extract_day - , subq_13.ds__extract_dow - , subq_13.ds__extract_doy - , subq_13.created_at__day - , subq_13.created_at__week - , subq_13.created_at__month - , subq_13.created_at__quarter - , subq_13.created_at__year - , subq_13.created_at__extract_year - , subq_13.created_at__extract_quarter - , subq_13.created_at__extract_month - , subq_13.created_at__extract_day - , subq_13.created_at__extract_dow - , subq_13.created_at__extract_doy - , subq_13.listing__ds__day - , subq_13.listing__ds__week - , subq_13.listing__ds__month - , subq_13.listing__ds__quarter - , subq_13.listing__ds__year - , subq_13.listing__ds__extract_year - , subq_13.listing__ds__extract_quarter - , subq_13.listing__ds__extract_month - , subq_13.listing__ds__extract_day - , subq_13.listing__ds__extract_dow - , subq_13.listing__ds__extract_doy - , subq_13.listing__created_at__day - , subq_13.listing__created_at__week - , subq_13.listing__created_at__month - , subq_13.listing__created_at__quarter - , subq_13.listing__created_at__year - , subq_13.listing__created_at__extract_year - , subq_13.listing__created_at__extract_quarter - , subq_13.listing__created_at__extract_month - , subq_13.listing__created_at__extract_day - , subq_13.listing__created_at__extract_dow - , subq_13.listing__created_at__extract_doy - , subq_13.ds__day AS metric_time__day - , subq_13.ds__week AS metric_time__week - , subq_13.ds__month AS metric_time__month - , subq_13.ds__quarter AS metric_time__quarter - , subq_13.ds__year AS metric_time__year - , subq_13.ds__extract_year AS metric_time__extract_year - , subq_13.ds__extract_quarter AS metric_time__extract_quarter - , subq_13.ds__extract_month AS metric_time__extract_month - , subq_13.ds__extract_day AS metric_time__extract_day - , subq_13.ds__extract_dow AS metric_time__extract_dow - , subq_13.ds__extract_doy AS metric_time__extract_doy - , subq_13.listing - , subq_13.user - , subq_13.listing__user - , subq_13.country_latest - , subq_13.is_lux_latest - , subq_13.capacity_latest - , subq_13.listing__country_latest - , subq_13.listing__is_lux_latest - , subq_13.listing__capacity_latest - , subq_13.listings - , subq_13.largest_listing - , subq_13.smallest_listing + 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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_13 - ) subq_14 - ) subq_15 + , 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_22 + ) subq_23 + ) subq_24 ON - subq_12.listing = subq_15.listing - ) subq_16 - ) subq_17 + subq_21.listing = subq_24.listing + ) subq_25 + ) subq_26 GROUP BY - subq_17.ds__day - , subq_17.listing__country_latest - ) subq_18 - ) subq_19 + subq_26.ds__day + , subq_26.listing__country_latest + ) subq_27 + ) subq_28 ON ( - subq_9.listing__country_latest = subq_19.listing__country_latest + subq_18.listing__country_latest = subq_28.listing__country_latest ) AND ( - subq_9.ds__day = subq_19.ds__day + subq_18.ds__day = subq_28.ds__day ) GROUP BY - COALESCE(subq_9.ds__day, subq_19.ds__day) - , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) -) subq_20 + COALESCE(subq_18.ds__day, subq_28.ds__day) + , COALESCE(subq_18.listing__country_latest, subq_28.listing__country_latest) +) subq_29 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 5b65e65d85..75a09cbc63 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -6,19 +6,19 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest - , MAX(subq_30.bookings) AS bookings - , MAX(subq_40.views) AS views + COALESCE(subq_39.ds__day, subq_49.ds__day) AS ds__day + , COALESCE(subq_39.listing__country_latest, subq_49.listing__country_latest) AS listing__country_latest + , MAX(subq_39.bookings) AS bookings + , MAX(subq_49.views) AS views FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_23.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + subq_32.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_32.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -27,25 +27,25 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_23.listing = listings_latest_src_28005.listing_id + subq_32.listing = listings_latest_src_28000.listing_id GROUP BY - subq_23.ds__day - , listings_latest_src_28005.country - ) subq_30 + subq_32.ds__day + , listings_latest_src_28000.country + ) subq_39 FULL OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_33.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_33.views) AS views + subq_42.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_42.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' @@ -54,23 +54,23 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views - FROM ***************************.fct_views views_source_src_28010 - ) subq_33 + FROM ***************************.fct_views views_source_src_28000 + ) subq_42 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_33.listing = listings_latest_src_28005.listing_id + subq_42.listing = listings_latest_src_28000.listing_id GROUP BY - subq_33.ds__day - , listings_latest_src_28005.country - ) subq_40 + subq_42.ds__day + , listings_latest_src_28000.country + ) subq_49 ON ( - subq_30.listing__country_latest = subq_40.listing__country_latest + subq_39.listing__country_latest = subq_49.listing__country_latest ) AND ( - subq_30.ds__day = subq_40.ds__day + subq_39.ds__day = subq_49.ds__day ) GROUP BY - COALESCE(subq_30.ds__day, subq_40.ds__day) - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) -) subq_41 + COALESCE(subq_39.ds__day, subq_49.ds__day) + , COALESCE(subq_39.listing__country_latest, subq_49.listing__country_latest) +) subq_50 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 3dbab396a9..c7aabe5705 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -28,93 +28,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 LEFT OUTER JOIN ( @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql index 7c57c360fb..c943b1a8d9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Aggregate Measures SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings , COUNT(DISTINCT subq_7.bookers) AS bookers FROM ( @@ -18,13 +18,13 @@ FROM ( listing_id AS listing , 1 AS bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY subq_7.listing - , listings_latest_src_28005.country + , listings_latest_src_28000.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0.sql index d2b2fe8dad..069df1629d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0_optimized.sql index 3bda7562bf..65e701e3dd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0_optimized.sql @@ -7,15 +7,15 @@ FROM ( -- Join Standard Outputs -- Aggregate Measures SELECT - bookings_source_src_28001.listing_id AS listing - , listings_latest_src_28005.country AS listing__country_latest - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.listing_id AS listing + , listings_latest_src_28000.country AS listing__country_latest + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY - bookings_source_src_28001.listing_id - , listings_latest_src_28005.country + bookings_source_src_28000.listing_id + , listings_latest_src_28000.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0.sql index 3a0b9aba09..5414f95860 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0_optimized.sql index db53f26587..d0d15f6943 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0_optimized.sql @@ -6,5 +6,5 @@ SELECT DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0.sql index 8d7833c4da..ed1028fb88 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -190,32 +190,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0_optimized.sql index 8cc8a2b867..c4e57d3c86 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,13 +5,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.country AS listing__country_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.country AS listing__country_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql index 884b765da5..0962aa9958 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql index bee3a232b6..96c5d5bb3a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY - listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_node__plan0.sql index e8e12063d5..4c0230bef5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_node__plan0.sql @@ -6,91 +6,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_node__plan0_optimized.sql index bfbf5ff951..554ce484fb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_node__plan0_optimized.sql @@ -2,4 +2,4 @@ -- Pass Only Elements: ['bookings',] SELECT 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0.sql index ae00bb04ec..6c7624e9c6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0_optimized.sql index 755a4d39e2..5ee87ba25f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0_optimized.sql @@ -8,6 +8,6 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_3 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index 21fc0ca626..d1eb9e6cdf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index d5d4ba056e..6054b232dc 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0.sql index 60b8dc17c7..6556fc936f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index 9c1b9ee488..836bd707a7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0.sql index 8573c54b5e..2c925cc021 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 695cf9c062..e4f47734b0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_aggregation_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_aggregation_node__plan0.sql index 693664c2e8..d3f9a7fb97 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_aggregation_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_aggregation_node__plan0.sql @@ -16,92 +16,92 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_aggregation_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_aggregation_node__plan0_optimized.sql index 64fc2826b9..6e5528a6c9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_aggregation_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_aggregation_node__plan0_optimized.sql @@ -6,4 +6,4 @@ SELECT , SUM(CASE WHEN is_instant THEN 1 ELSE 0 END) AS instant_bookings , COUNT(DISTINCT guest_id) AS bookers , AVG(booking_value) AS average_booking_value -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0.sql index 2aa11d8ca7..f3ed9fa304 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0.sql @@ -14,93 +14,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 LEFT OUTER JOIN ( @@ -112,62 +112,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON @@ -181,62 +181,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0_optimized.sql index b9cecc48d8..7d9c669f54 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -18,7 +18,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_9 ON subq_7.listing = subq_9.listing @@ -28,7 +28,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_11 ON subq_7.listing = subq_11.listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0.sql index 05e8717a48..49a2ea3b75 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0.sql @@ -26,93 +26,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0_optimized.sql index fd8a1ff597..bcebfe9d5f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 GROUP BY ds__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0.sql index 6a69a7ef1b..1d89d14791 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 LEFT OUTER JOIN ( @@ -110,62 +110,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0_optimized.sql index e03ffcce64..a1cd7ac335 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_5.listing = listings_latest_src_28005.listing_id + subq_5.listing = listings_latest_src_28000.listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0.sql index 5360aa4516..d94b68c968 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0.sql @@ -2,90 +2,90 @@ SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0_optimized.sql index e15f76d1de..9814c2d0cf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0_optimized.sql @@ -88,4 +88,4 @@ SELECT , listing_id AS booking__listing , guest_id AS booking__guest , host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_combine_output_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_combine_output_node__plan0.sql index a8375b02dd..a8d97dae7f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_combine_output_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_combine_output_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY @@ -128,93 +128,93 @@ FULL OUTER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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_3 ) subq_4 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_combine_output_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_combine_output_node__plan0_optimized.sql index a8375510d7..ad81788114 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_combine_output_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_combine_output_node__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( SELECT is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 GROUP BY is_instant @@ -33,7 +33,7 @@ FULL OUTER JOIN ( is_instant , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_10 GROUP BY is_instant diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0.sql index 760f45c973..08fdfa6034 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0_optimized.sql index cf47afc6bf..5ebe7177e8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Compute Metrics via Expressions SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -11,12 +11,12 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY subq_7.listing - , listings_latest_src_28005.country + , listings_latest_src_28000.country diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 0d00d2347f..a6aaccb999 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -1,693 +1,693 @@ -- Compute Metrics via Expressions SELECT - subq_20.ds__day - , subq_20.listing__country_latest - , CAST(subq_20.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_20.views, 0) AS DOUBLE PRECISION) AS bookings_per_view + subq_29.ds__day + , subq_29.listing__country_latest + , CAST(subq_29.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_29.views, 0) AS DOUBLE PRECISION) AS bookings_per_view FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.ds__day, subq_19.ds__day) AS ds__day - , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) AS listing__country_latest - , MAX(subq_9.bookings) AS bookings - , MAX(subq_19.views) AS views + COALESCE(subq_18.ds__day, subq_28.ds__day) AS ds__day + , COALESCE(subq_18.listing__country_latest, subq_28.listing__country_latest) AS listing__country_latest + , MAX(subq_18.bookings) AS bookings + , MAX(subq_28.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_8.ds__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_17.ds__day + , subq_17.listing__country_latest + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.ds__day - , subq_7.listing__country_latest - , SUM(subq_7.bookings) AS bookings + subq_16.ds__day + , subq_16.listing__country_latest + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] SELECT - subq_6.ds__day - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.ds__day + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.listing AS listing - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.ds__day AS ds__day + , subq_11.listing AS listing + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] SELECT - subq_1.ds__day - , subq_1.listing - , subq_1.bookings + subq_10.ds__day + , subq_10.listing + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 GROUP BY - subq_7.ds__day - , subq_7.listing__country_latest - ) subq_8 - ) subq_9 + subq_16.ds__day + , subq_16.listing__country_latest + ) subq_17 + ) subq_18 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_18.ds__day - , subq_18.listing__country_latest - , subq_18.views + subq_27.ds__day + , subq_27.listing__country_latest + , subq_27.views FROM ( -- Aggregate Measures SELECT - subq_17.ds__day - , subq_17.listing__country_latest - , SUM(subq_17.views) AS views + subq_26.ds__day + , subq_26.listing__country_latest + , SUM(subq_26.views) AS views FROM ( -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] SELECT - subq_16.ds__day - , subq_16.listing__country_latest - , subq_16.views + subq_25.ds__day + , subq_25.listing__country_latest + , subq_25.views FROM ( -- Join Standard Outputs SELECT - subq_12.ds__day AS ds__day - , subq_12.listing AS listing - , subq_15.country_latest AS listing__country_latest - , subq_12.views AS views + subq_21.ds__day AS ds__day + , subq_21.listing AS listing + , subq_24.country_latest AS listing__country_latest + , subq_21.views AS views FROM ( -- Pass Only Elements: ['views', 'ds__day', 'listing'] SELECT - subq_11.ds__day - , subq_11.listing - , subq_11.views + subq_20.ds__day + , subq_20.listing + , subq_20.views 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.view__ds__day - , subq_10.view__ds__week - , subq_10.view__ds__month - , subq_10.view__ds__quarter - , subq_10.view__ds__year - , subq_10.view__ds__extract_year - , subq_10.view__ds__extract_quarter - , subq_10.view__ds__extract_month - , subq_10.view__ds__extract_day - , subq_10.view__ds__extract_dow - , subq_10.view__ds__extract_doy - , subq_10.view__ds_partitioned__day - , subq_10.view__ds_partitioned__week - , subq_10.view__ds_partitioned__month - , subq_10.view__ds_partitioned__quarter - , subq_10.view__ds_partitioned__year - , subq_10.view__ds_partitioned__extract_year - , subq_10.view__ds_partitioned__extract_quarter - , subq_10.view__ds_partitioned__extract_month - , subq_10.view__ds_partitioned__extract_day - , subq_10.view__ds_partitioned__extract_dow - , subq_10.view__ds_partitioned__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.view__listing - , subq_10.view__user - , subq_10.views + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.view__ds__day + , subq_19.view__ds__week + , subq_19.view__ds__month + , subq_19.view__ds__quarter + , subq_19.view__ds__year + , subq_19.view__ds__extract_year + , subq_19.view__ds__extract_quarter + , subq_19.view__ds__extract_month + , subq_19.view__ds__extract_day + , subq_19.view__ds__extract_dow + , subq_19.view__ds__extract_doy + , subq_19.view__ds_partitioned__day + , subq_19.view__ds_partitioned__week + , subq_19.view__ds_partitioned__month + , subq_19.view__ds_partitioned__quarter + , subq_19.view__ds_partitioned__year + , subq_19.view__ds_partitioned__extract_year + , subq_19.view__ds_partitioned__extract_quarter + , subq_19.view__ds_partitioned__extract_month + , subq_19.view__ds_partitioned__extract_day + , subq_19.view__ds_partitioned__extract_dow + , subq_19.view__ds_partitioned__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.user + , subq_19.view__listing + , subq_19.view__user + , subq_19.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , DATE_TRUNC('day', views_source_src_28010.ds) AS ds__day - , DATE_TRUNC('week', views_source_src_28010.ds) AS ds__week - , DATE_TRUNC('month', views_source_src_28010.ds) AS ds__month - , DATE_TRUNC('quarter', views_source_src_28010.ds) AS ds__quarter - , DATE_TRUNC('year', views_source_src_28010.ds) AS ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS ds__extract_day - , EXTRACT(isodow FROM views_source_src_28010.ds) AS ds__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds) AS ds__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', views_source_src_28010.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', views_source_src_28010.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_28010.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_28010.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds) AS view__ds__day - , DATE_TRUNC('week', views_source_src_28010.ds) AS view__ds__week - , DATE_TRUNC('month', views_source_src_28010.ds) AS view__ds__month - , DATE_TRUNC('quarter', views_source_src_28010.ds) AS view__ds__quarter - , DATE_TRUNC('year', views_source_src_28010.ds) AS view__ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS view__ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS view__ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS view__ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS view__ds__extract_day - , EXTRACT(isodow FROM views_source_src_28010.ds) AS view__ds__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds) AS view__ds__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__day - , DATE_TRUNC('week', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__week - , DATE_TRUNC('month', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_day - , EXTRACT(isodow FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_doy - , views_source_src_28010.listing_id AS listing - , views_source_src_28010.user_id AS user - , views_source_src_28010.listing_id AS view__listing - , views_source_src_28010.user_id AS view__user - FROM ***************************.fct_views views_source_src_28010 - ) subq_10 - ) subq_11 - ) subq_12 + , DATE_TRUNC('day', views_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', views_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', views_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', views_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', views_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM views_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', views_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', views_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds) AS view__ds__day + , DATE_TRUNC('week', views_source_src_28000.ds) AS view__ds__week + , DATE_TRUNC('month', views_source_src_28000.ds) AS view__ds__month + , DATE_TRUNC('quarter', views_source_src_28000.ds) AS view__ds__quarter + , DATE_TRUNC('year', views_source_src_28000.ds) AS view__ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS view__ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS view__ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS view__ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS view__ds__extract_day + , EXTRACT(isodow FROM views_source_src_28000.ds) AS view__ds__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds) AS view__ds__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__day + , DATE_TRUNC('week', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__week + , DATE_TRUNC('month', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_day + , EXTRACT(isodow FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_doy + , views_source_src_28000.listing_id AS listing + , views_source_src_28000.user_id AS user + , views_source_src_28000.listing_id AS view__listing + , views_source_src_28000.user_id AS view__user + FROM ***************************.fct_views views_source_src_28000 + ) subq_19 + ) subq_20 + ) subq_21 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_14.listing - , subq_14.country_latest + subq_23.listing + , subq_23.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_13.ds__day - , subq_13.ds__week - , subq_13.ds__month - , subq_13.ds__quarter - , subq_13.ds__year - , subq_13.ds__extract_year - , subq_13.ds__extract_quarter - , subq_13.ds__extract_month - , subq_13.ds__extract_day - , subq_13.ds__extract_dow - , subq_13.ds__extract_doy - , subq_13.created_at__day - , subq_13.created_at__week - , subq_13.created_at__month - , subq_13.created_at__quarter - , subq_13.created_at__year - , subq_13.created_at__extract_year - , subq_13.created_at__extract_quarter - , subq_13.created_at__extract_month - , subq_13.created_at__extract_day - , subq_13.created_at__extract_dow - , subq_13.created_at__extract_doy - , subq_13.listing__ds__day - , subq_13.listing__ds__week - , subq_13.listing__ds__month - , subq_13.listing__ds__quarter - , subq_13.listing__ds__year - , subq_13.listing__ds__extract_year - , subq_13.listing__ds__extract_quarter - , subq_13.listing__ds__extract_month - , subq_13.listing__ds__extract_day - , subq_13.listing__ds__extract_dow - , subq_13.listing__ds__extract_doy - , subq_13.listing__created_at__day - , subq_13.listing__created_at__week - , subq_13.listing__created_at__month - , subq_13.listing__created_at__quarter - , subq_13.listing__created_at__year - , subq_13.listing__created_at__extract_year - , subq_13.listing__created_at__extract_quarter - , subq_13.listing__created_at__extract_month - , subq_13.listing__created_at__extract_day - , subq_13.listing__created_at__extract_dow - , subq_13.listing__created_at__extract_doy - , subq_13.ds__day AS metric_time__day - , subq_13.ds__week AS metric_time__week - , subq_13.ds__month AS metric_time__month - , subq_13.ds__quarter AS metric_time__quarter - , subq_13.ds__year AS metric_time__year - , subq_13.ds__extract_year AS metric_time__extract_year - , subq_13.ds__extract_quarter AS metric_time__extract_quarter - , subq_13.ds__extract_month AS metric_time__extract_month - , subq_13.ds__extract_day AS metric_time__extract_day - , subq_13.ds__extract_dow AS metric_time__extract_dow - , subq_13.ds__extract_doy AS metric_time__extract_doy - , subq_13.listing - , subq_13.user - , subq_13.listing__user - , subq_13.country_latest - , subq_13.is_lux_latest - , subq_13.capacity_latest - , subq_13.listing__country_latest - , subq_13.listing__is_lux_latest - , subq_13.listing__capacity_latest - , subq_13.listings - , subq_13.largest_listing - , subq_13.smallest_listing + 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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_13 - ) subq_14 - ) subq_15 + , 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_22 + ) subq_23 + ) subq_24 ON - subq_12.listing = subq_15.listing - ) subq_16 - ) subq_17 + subq_21.listing = subq_24.listing + ) subq_25 + ) subq_26 GROUP BY - subq_17.ds__day - , subq_17.listing__country_latest - ) subq_18 - ) subq_19 + subq_26.ds__day + , subq_26.listing__country_latest + ) subq_27 + ) subq_28 ON ( - subq_9.listing__country_latest = subq_19.listing__country_latest + subq_18.listing__country_latest = subq_28.listing__country_latest ) AND ( - subq_9.ds__day = subq_19.ds__day + subq_18.ds__day = subq_28.ds__day ) GROUP BY - COALESCE(subq_9.ds__day, subq_19.ds__day) - , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) -) subq_20 + COALESCE(subq_18.ds__day, subq_28.ds__day) + , COALESCE(subq_18.listing__country_latest, subq_28.listing__country_latest) +) subq_29 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 07a0d3efe7..8289fb48f2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -6,19 +6,19 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest - , MAX(subq_30.bookings) AS bookings - , MAX(subq_40.views) AS views + COALESCE(subq_39.ds__day, subq_49.ds__day) AS ds__day + , COALESCE(subq_39.listing__country_latest, subq_49.listing__country_latest) AS listing__country_latest + , MAX(subq_39.bookings) AS bookings + , MAX(subq_49.views) AS views FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_23.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + subq_32.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_32.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -27,25 +27,25 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_23.listing = listings_latest_src_28005.listing_id + subq_32.listing = listings_latest_src_28000.listing_id GROUP BY - subq_23.ds__day - , listings_latest_src_28005.country - ) subq_30 + subq_32.ds__day + , listings_latest_src_28000.country + ) subq_39 FULL OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_33.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_33.views) AS views + subq_42.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_42.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' @@ -54,23 +54,23 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views - FROM ***************************.fct_views views_source_src_28010 - ) subq_33 + FROM ***************************.fct_views views_source_src_28000 + ) subq_42 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_33.listing = listings_latest_src_28005.listing_id + subq_42.listing = listings_latest_src_28000.listing_id GROUP BY - subq_33.ds__day - , listings_latest_src_28005.country - ) subq_40 + subq_42.ds__day + , listings_latest_src_28000.country + ) subq_49 ON ( - subq_30.listing__country_latest = subq_40.listing__country_latest + subq_39.listing__country_latest = subq_49.listing__country_latest ) AND ( - subq_30.ds__day = subq_40.ds__day + subq_39.ds__day = subq_49.ds__day ) GROUP BY - COALESCE(subq_30.ds__day, subq_40.ds__day) - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) -) subq_41 + COALESCE(subq_39.ds__day, subq_49.ds__day) + , COALESCE(subq_39.listing__country_latest, subq_49.listing__country_latest) +) subq_50 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 7134ac9ae1..01a2b684f3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -28,93 +28,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 LEFT OUTER JOIN ( @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql index 38e9fae7d2..b2cd839070 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Aggregate Measures SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings , COUNT(DISTINCT subq_7.bookers) AS bookers FROM ( @@ -18,13 +18,13 @@ FROM ( listing_id AS listing , 1 AS bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY subq_7.listing - , listings_latest_src_28005.country + , listings_latest_src_28000.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0.sql index d2b2fe8dad..069df1629d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0_optimized.sql index 3bda7562bf..65e701e3dd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0_optimized.sql @@ -7,15 +7,15 @@ FROM ( -- Join Standard Outputs -- Aggregate Measures SELECT - bookings_source_src_28001.listing_id AS listing - , listings_latest_src_28005.country AS listing__country_latest - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.listing_id AS listing + , listings_latest_src_28000.country AS listing__country_latest + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY - bookings_source_src_28001.listing_id - , listings_latest_src_28005.country + bookings_source_src_28000.listing_id + , listings_latest_src_28000.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0.sql index 3a0b9aba09..5414f95860 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0_optimized.sql index db53f26587..d0d15f6943 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0_optimized.sql @@ -6,5 +6,5 @@ SELECT DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0.sql index 8d7833c4da..ed1028fb88 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -190,32 +190,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0_optimized.sql index 8cc8a2b867..c4e57d3c86 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,13 +5,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.country AS listing__country_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.country AS listing__country_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql index 884b765da5..0962aa9958 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql index bee3a232b6..96c5d5bb3a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY - listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_node__plan0.sql index e8e12063d5..4c0230bef5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_node__plan0.sql @@ -6,91 +6,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_node__plan0_optimized.sql index bfbf5ff951..554ce484fb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_node__plan0_optimized.sql @@ -2,4 +2,4 @@ -- Pass Only Elements: ['bookings',] SELECT 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0.sql index ae00bb04ec..6c7624e9c6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0_optimized.sql index 755a4d39e2..5ee87ba25f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0_optimized.sql @@ -8,6 +8,6 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_3 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index 21fc0ca626..d1eb9e6cdf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index d5d4ba056e..6054b232dc 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0.sql index 25edad3460..cd070b2730 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index e268d266eb..21b1f16711 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0.sql index 8573c54b5e..2c925cc021 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 695cf9c062..e4f47734b0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_aggregation_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_aggregation_node__plan0.sql index 693664c2e8..d3f9a7fb97 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_aggregation_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_aggregation_node__plan0.sql @@ -16,92 +16,92 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_aggregation_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_aggregation_node__plan0_optimized.sql index 64fc2826b9..6e5528a6c9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_aggregation_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_aggregation_node__plan0_optimized.sql @@ -6,4 +6,4 @@ SELECT , SUM(CASE WHEN is_instant THEN 1 ELSE 0 END) AS instant_bookings , COUNT(DISTINCT guest_id) AS bookers , AVG(booking_value) AS average_booking_value -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0.sql index 2aa11d8ca7..f3ed9fa304 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0.sql @@ -14,93 +14,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 LEFT OUTER JOIN ( @@ -112,62 +112,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON @@ -181,62 +181,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0_optimized.sql index b9cecc48d8..7d9c669f54 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -18,7 +18,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_9 ON subq_7.listing = subq_9.listing @@ -28,7 +28,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_11 ON subq_7.listing = subq_11.listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0.sql index 05e8717a48..49a2ea3b75 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0.sql @@ -26,93 +26,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0_optimized.sql index fd8a1ff597..bcebfe9d5f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 GROUP BY ds__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0.sql index 6a69a7ef1b..1d89d14791 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 LEFT OUTER JOIN ( @@ -110,62 +110,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0_optimized.sql index e03ffcce64..a1cd7ac335 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_5.listing = listings_latest_src_28005.listing_id + subq_5.listing = listings_latest_src_28000.listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0.sql index 5360aa4516..d94b68c968 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0.sql @@ -2,90 +2,90 @@ SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0_optimized.sql index e15f76d1de..9814c2d0cf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0_optimized.sql @@ -88,4 +88,4 @@ SELECT , listing_id AS booking__listing , guest_id AS booking__guest , host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_combine_output_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_combine_output_node__plan0.sql index b4a2ffc5f2..c67c97979c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_combine_output_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_combine_output_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY @@ -128,93 +128,93 @@ FULL OUTER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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_3 ) subq_4 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_combine_output_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_combine_output_node__plan0_optimized.sql index a8375510d7..ad81788114 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_combine_output_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_combine_output_node__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( SELECT is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 GROUP BY is_instant @@ -33,7 +33,7 @@ FULL OUTER JOIN ( is_instant , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_10 GROUP BY is_instant diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0.sql index fcf32197e7..a94865f00e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0_optimized.sql index cf47afc6bf..5ebe7177e8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Compute Metrics via Expressions SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -11,12 +11,12 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY subq_7.listing - , listings_latest_src_28005.country + , listings_latest_src_28000.country diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index f7a597faea..df7e4469bd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -1,693 +1,693 @@ -- Compute Metrics via Expressions SELECT - subq_20.ds__day - , subq_20.listing__country_latest - , CAST(subq_20.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_20.views, 0) AS DOUBLE PRECISION) AS bookings_per_view + subq_29.ds__day + , subq_29.listing__country_latest + , CAST(subq_29.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_29.views, 0) AS DOUBLE PRECISION) AS bookings_per_view FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.ds__day, subq_19.ds__day) AS ds__day - , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) AS listing__country_latest - , MAX(subq_9.bookings) AS bookings - , MAX(subq_19.views) AS views + COALESCE(subq_18.ds__day, subq_28.ds__day) AS ds__day + , COALESCE(subq_18.listing__country_latest, subq_28.listing__country_latest) AS listing__country_latest + , MAX(subq_18.bookings) AS bookings + , MAX(subq_28.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_8.ds__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_17.ds__day + , subq_17.listing__country_latest + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.ds__day - , subq_7.listing__country_latest - , SUM(subq_7.bookings) AS bookings + subq_16.ds__day + , subq_16.listing__country_latest + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] SELECT - subq_6.ds__day - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.ds__day + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.listing AS listing - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.ds__day AS ds__day + , subq_11.listing AS listing + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] SELECT - subq_1.ds__day - , subq_1.listing - , subq_1.bookings + subq_10.ds__day + , subq_10.listing + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 GROUP BY - subq_7.ds__day - , subq_7.listing__country_latest - ) subq_8 - ) subq_9 + subq_16.ds__day + , subq_16.listing__country_latest + ) subq_17 + ) subq_18 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_18.ds__day - , subq_18.listing__country_latest - , subq_18.views + subq_27.ds__day + , subq_27.listing__country_latest + , subq_27.views FROM ( -- Aggregate Measures SELECT - subq_17.ds__day - , subq_17.listing__country_latest - , SUM(subq_17.views) AS views + subq_26.ds__day + , subq_26.listing__country_latest + , SUM(subq_26.views) AS views FROM ( -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] SELECT - subq_16.ds__day - , subq_16.listing__country_latest - , subq_16.views + subq_25.ds__day + , subq_25.listing__country_latest + , subq_25.views FROM ( -- Join Standard Outputs SELECT - subq_12.ds__day AS ds__day - , subq_12.listing AS listing - , subq_15.country_latest AS listing__country_latest - , subq_12.views AS views + subq_21.ds__day AS ds__day + , subq_21.listing AS listing + , subq_24.country_latest AS listing__country_latest + , subq_21.views AS views FROM ( -- Pass Only Elements: ['views', 'ds__day', 'listing'] SELECT - subq_11.ds__day - , subq_11.listing - , subq_11.views + subq_20.ds__day + , subq_20.listing + , subq_20.views 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.view__ds__day - , subq_10.view__ds__week - , subq_10.view__ds__month - , subq_10.view__ds__quarter - , subq_10.view__ds__year - , subq_10.view__ds__extract_year - , subq_10.view__ds__extract_quarter - , subq_10.view__ds__extract_month - , subq_10.view__ds__extract_day - , subq_10.view__ds__extract_dow - , subq_10.view__ds__extract_doy - , subq_10.view__ds_partitioned__day - , subq_10.view__ds_partitioned__week - , subq_10.view__ds_partitioned__month - , subq_10.view__ds_partitioned__quarter - , subq_10.view__ds_partitioned__year - , subq_10.view__ds_partitioned__extract_year - , subq_10.view__ds_partitioned__extract_quarter - , subq_10.view__ds_partitioned__extract_month - , subq_10.view__ds_partitioned__extract_day - , subq_10.view__ds_partitioned__extract_dow - , subq_10.view__ds_partitioned__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.view__listing - , subq_10.view__user - , subq_10.views + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.view__ds__day + , subq_19.view__ds__week + , subq_19.view__ds__month + , subq_19.view__ds__quarter + , subq_19.view__ds__year + , subq_19.view__ds__extract_year + , subq_19.view__ds__extract_quarter + , subq_19.view__ds__extract_month + , subq_19.view__ds__extract_day + , subq_19.view__ds__extract_dow + , subq_19.view__ds__extract_doy + , subq_19.view__ds_partitioned__day + , subq_19.view__ds_partitioned__week + , subq_19.view__ds_partitioned__month + , subq_19.view__ds_partitioned__quarter + , subq_19.view__ds_partitioned__year + , subq_19.view__ds_partitioned__extract_year + , subq_19.view__ds_partitioned__extract_quarter + , subq_19.view__ds_partitioned__extract_month + , subq_19.view__ds_partitioned__extract_day + , subq_19.view__ds_partitioned__extract_dow + , subq_19.view__ds_partitioned__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.user + , subq_19.view__listing + , subq_19.view__user + , subq_19.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , DATE_TRUNC('day', views_source_src_28010.ds) AS ds__day - , DATE_TRUNC('week', views_source_src_28010.ds) AS ds__week - , DATE_TRUNC('month', views_source_src_28010.ds) AS ds__month - , DATE_TRUNC('quarter', views_source_src_28010.ds) AS ds__quarter - , DATE_TRUNC('year', views_source_src_28010.ds) AS ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM views_source_src_28010.ds) = 0 THEN EXTRACT(dow FROM views_source_src_28010.ds) + 7 ELSE EXTRACT(dow FROM views_source_src_28010.ds) END AS ds__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds) AS ds__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', views_source_src_28010.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', views_source_src_28010.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_28010.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_28010.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM views_source_src_28010.ds_partitioned) = 0 THEN EXTRACT(dow FROM views_source_src_28010.ds_partitioned) + 7 ELSE EXTRACT(dow FROM views_source_src_28010.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds) AS view__ds__day - , DATE_TRUNC('week', views_source_src_28010.ds) AS view__ds__week - , DATE_TRUNC('month', views_source_src_28010.ds) AS view__ds__month - , DATE_TRUNC('quarter', views_source_src_28010.ds) AS view__ds__quarter - , DATE_TRUNC('year', views_source_src_28010.ds) AS view__ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS view__ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS view__ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS view__ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS view__ds__extract_day - , CASE WHEN EXTRACT(dow FROM views_source_src_28010.ds) = 0 THEN EXTRACT(dow FROM views_source_src_28010.ds) + 7 ELSE EXTRACT(dow FROM views_source_src_28010.ds) END AS view__ds__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds) AS view__ds__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__day - , DATE_TRUNC('week', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__week - , DATE_TRUNC('month', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM views_source_src_28010.ds_partitioned) = 0 THEN EXTRACT(dow FROM views_source_src_28010.ds_partitioned) + 7 ELSE EXTRACT(dow FROM views_source_src_28010.ds_partitioned) END AS view__ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_doy - , views_source_src_28010.listing_id AS listing - , views_source_src_28010.user_id AS user - , views_source_src_28010.listing_id AS view__listing - , views_source_src_28010.user_id AS view__user - FROM ***************************.fct_views views_source_src_28010 - ) subq_10 - ) subq_11 - ) subq_12 + , DATE_TRUNC('day', views_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', views_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', views_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', views_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', views_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM views_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM views_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM views_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', views_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', views_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM views_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM views_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM views_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds) AS view__ds__day + , DATE_TRUNC('week', views_source_src_28000.ds) AS view__ds__week + , DATE_TRUNC('month', views_source_src_28000.ds) AS view__ds__month + , DATE_TRUNC('quarter', views_source_src_28000.ds) AS view__ds__quarter + , DATE_TRUNC('year', views_source_src_28000.ds) AS view__ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS view__ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS view__ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS view__ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS view__ds__extract_day + , CASE WHEN EXTRACT(dow FROM views_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM views_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM views_source_src_28000.ds) END AS view__ds__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds) AS view__ds__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__day + , DATE_TRUNC('week', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__week + , DATE_TRUNC('month', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM views_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM views_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM views_source_src_28000.ds_partitioned) END AS view__ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_doy + , views_source_src_28000.listing_id AS listing + , views_source_src_28000.user_id AS user + , views_source_src_28000.listing_id AS view__listing + , views_source_src_28000.user_id AS view__user + FROM ***************************.fct_views views_source_src_28000 + ) subq_19 + ) subq_20 + ) subq_21 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_14.listing - , subq_14.country_latest + subq_23.listing + , subq_23.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_13.ds__day - , subq_13.ds__week - , subq_13.ds__month - , subq_13.ds__quarter - , subq_13.ds__year - , subq_13.ds__extract_year - , subq_13.ds__extract_quarter - , subq_13.ds__extract_month - , subq_13.ds__extract_day - , subq_13.ds__extract_dow - , subq_13.ds__extract_doy - , subq_13.created_at__day - , subq_13.created_at__week - , subq_13.created_at__month - , subq_13.created_at__quarter - , subq_13.created_at__year - , subq_13.created_at__extract_year - , subq_13.created_at__extract_quarter - , subq_13.created_at__extract_month - , subq_13.created_at__extract_day - , subq_13.created_at__extract_dow - , subq_13.created_at__extract_doy - , subq_13.listing__ds__day - , subq_13.listing__ds__week - , subq_13.listing__ds__month - , subq_13.listing__ds__quarter - , subq_13.listing__ds__year - , subq_13.listing__ds__extract_year - , subq_13.listing__ds__extract_quarter - , subq_13.listing__ds__extract_month - , subq_13.listing__ds__extract_day - , subq_13.listing__ds__extract_dow - , subq_13.listing__ds__extract_doy - , subq_13.listing__created_at__day - , subq_13.listing__created_at__week - , subq_13.listing__created_at__month - , subq_13.listing__created_at__quarter - , subq_13.listing__created_at__year - , subq_13.listing__created_at__extract_year - , subq_13.listing__created_at__extract_quarter - , subq_13.listing__created_at__extract_month - , subq_13.listing__created_at__extract_day - , subq_13.listing__created_at__extract_dow - , subq_13.listing__created_at__extract_doy - , subq_13.ds__day AS metric_time__day - , subq_13.ds__week AS metric_time__week - , subq_13.ds__month AS metric_time__month - , subq_13.ds__quarter AS metric_time__quarter - , subq_13.ds__year AS metric_time__year - , subq_13.ds__extract_year AS metric_time__extract_year - , subq_13.ds__extract_quarter AS metric_time__extract_quarter - , subq_13.ds__extract_month AS metric_time__extract_month - , subq_13.ds__extract_day AS metric_time__extract_day - , subq_13.ds__extract_dow AS metric_time__extract_dow - , subq_13.ds__extract_doy AS metric_time__extract_doy - , subq_13.listing - , subq_13.user - , subq_13.listing__user - , subq_13.country_latest - , subq_13.is_lux_latest - , subq_13.capacity_latest - , subq_13.listing__country_latest - , subq_13.listing__is_lux_latest - , subq_13.listing__capacity_latest - , subq_13.listings - , subq_13.largest_listing - , subq_13.smallest_listing + 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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_13 - ) subq_14 - ) subq_15 + , 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_22 + ) subq_23 + ) subq_24 ON - subq_12.listing = subq_15.listing - ) subq_16 - ) subq_17 + subq_21.listing = subq_24.listing + ) subq_25 + ) subq_26 GROUP BY - subq_17.ds__day - , subq_17.listing__country_latest - ) subq_18 - ) subq_19 + subq_26.ds__day + , subq_26.listing__country_latest + ) subq_27 + ) subq_28 ON ( - subq_9.listing__country_latest = subq_19.listing__country_latest + subq_18.listing__country_latest = subq_28.listing__country_latest ) AND ( - subq_9.ds__day = subq_19.ds__day + subq_18.ds__day = subq_28.ds__day ) GROUP BY - COALESCE(subq_9.ds__day, subq_19.ds__day) - , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) -) subq_20 + COALESCE(subq_18.ds__day, subq_28.ds__day) + , COALESCE(subq_18.listing__country_latest, subq_28.listing__country_latest) +) subq_29 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 07a0d3efe7..8289fb48f2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -6,19 +6,19 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest - , MAX(subq_30.bookings) AS bookings - , MAX(subq_40.views) AS views + COALESCE(subq_39.ds__day, subq_49.ds__day) AS ds__day + , COALESCE(subq_39.listing__country_latest, subq_49.listing__country_latest) AS listing__country_latest + , MAX(subq_39.bookings) AS bookings + , MAX(subq_49.views) AS views FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_23.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + subq_32.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_32.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -27,25 +27,25 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_23.listing = listings_latest_src_28005.listing_id + subq_32.listing = listings_latest_src_28000.listing_id GROUP BY - subq_23.ds__day - , listings_latest_src_28005.country - ) subq_30 + subq_32.ds__day + , listings_latest_src_28000.country + ) subq_39 FULL OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_33.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_33.views) AS views + subq_42.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_42.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' @@ -54,23 +54,23 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views - FROM ***************************.fct_views views_source_src_28010 - ) subq_33 + FROM ***************************.fct_views views_source_src_28000 + ) subq_42 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_33.listing = listings_latest_src_28005.listing_id + subq_42.listing = listings_latest_src_28000.listing_id GROUP BY - subq_33.ds__day - , listings_latest_src_28005.country - ) subq_40 + subq_42.ds__day + , listings_latest_src_28000.country + ) subq_49 ON ( - subq_30.listing__country_latest = subq_40.listing__country_latest + subq_39.listing__country_latest = subq_49.listing__country_latest ) AND ( - subq_30.ds__day = subq_40.ds__day + subq_39.ds__day = subq_49.ds__day ) GROUP BY - COALESCE(subq_30.ds__day, subq_40.ds__day) - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) -) subq_41 + COALESCE(subq_39.ds__day, subq_49.ds__day) + , COALESCE(subq_39.listing__country_latest, subq_49.listing__country_latest) +) subq_50 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 58a8bb791f..c8f22b47b7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -28,93 +28,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql index 38e9fae7d2..b2cd839070 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Aggregate Measures SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings , COUNT(DISTINCT subq_7.bookers) AS bookers FROM ( @@ -18,13 +18,13 @@ FROM ( listing_id AS listing , 1 AS bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY subq_7.listing - , listings_latest_src_28005.country + , listings_latest_src_28000.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0.sql index d55d97c5b2..a332bba687 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0_optimized.sql index 3bda7562bf..65e701e3dd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0_optimized.sql @@ -7,15 +7,15 @@ FROM ( -- Join Standard Outputs -- Aggregate Measures SELECT - bookings_source_src_28001.listing_id AS listing - , listings_latest_src_28005.country AS listing__country_latest - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.listing_id AS listing + , listings_latest_src_28000.country AS listing__country_latest + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY - bookings_source_src_28001.listing_id - , listings_latest_src_28005.country + bookings_source_src_28000.listing_id + , listings_latest_src_28000.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0.sql index 7bbfa4627e..1a515595bf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0_optimized.sql index db53f26587..d0d15f6943 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0_optimized.sql @@ -6,5 +6,5 @@ SELECT DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0.sql index 384068ec70..c59a5e39af 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -190,32 +190,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0_optimized.sql index 8cc8a2b867..c4e57d3c86 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,13 +5,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.country AS listing__country_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.country AS listing__country_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql index 5258faf635..6ada21e5f4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql index bee3a232b6..96c5d5bb3a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY - listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_node__plan0.sql index c6bba35a07..f55759536d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_node__plan0.sql @@ -6,91 +6,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_node__plan0_optimized.sql index bfbf5ff951..554ce484fb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_node__plan0_optimized.sql @@ -2,4 +2,4 @@ -- Pass Only Elements: ['bookings',] SELECT 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0.sql index c07f8c5bca..1cc84ea68b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0_optimized.sql index 755a4d39e2..5ee87ba25f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0_optimized.sql @@ -8,6 +8,6 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_3 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index ec28e376e6..08f2336170 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index d5d4ba056e..6054b232dc 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0.sql index 35a548e0a4..dc9b6b2769 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index cb1797bad8..61bc9299ec 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0.sql index 1b79c4cf87..b0708bcdc2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 695cf9c062..e4f47734b0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_aggregation_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_aggregation_node__plan0.sql index d67aff3bb0..b6273f4c1f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_aggregation_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_aggregation_node__plan0.sql @@ -16,92 +16,92 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_aggregation_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_aggregation_node__plan0_optimized.sql index 64fc2826b9..6e5528a6c9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_aggregation_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_aggregation_node__plan0_optimized.sql @@ -6,4 +6,4 @@ SELECT , SUM(CASE WHEN is_instant THEN 1 ELSE 0 END) AS instant_bookings , COUNT(DISTINCT guest_id) AS bookers , AVG(booking_value) AS average_booking_value -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0.sql index 6a96fe1f63..7c1221217a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0.sql @@ -14,93 +14,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -112,62 +112,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON @@ -181,62 +181,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0_optimized.sql index b9cecc48d8..7d9c669f54 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -18,7 +18,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_9 ON subq_7.listing = subq_9.listing @@ -28,7 +28,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_11 ON subq_7.listing = subq_11.listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0.sql index dd8c53b524..64beab1078 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0.sql @@ -26,93 +26,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0_optimized.sql index fd8a1ff597..bcebfe9d5f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 GROUP BY ds__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0.sql index 5eb1ecbbfd..59c21d9f82 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -110,62 +110,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0_optimized.sql index e03ffcce64..a1cd7ac335 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_5.listing = listings_latest_src_28005.listing_id + subq_5.listing = listings_latest_src_28000.listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0.sql index 0d0f27eb45..e312066a03 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0.sql @@ -2,90 +2,90 @@ SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0_optimized.sql index a8f0120386..430bb9b883 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0_optimized.sql @@ -88,4 +88,4 @@ SELECT , listing_id AS booking__listing , guest_id AS booking__guest , host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_combine_output_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_combine_output_node__plan0.sql index c9b56f342d..cd50272c26 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_combine_output_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_combine_output_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY @@ -128,93 +128,93 @@ FULL OUTER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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_3 ) subq_4 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_combine_output_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_combine_output_node__plan0_optimized.sql index a8375510d7..ad81788114 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_combine_output_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_combine_output_node__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( SELECT is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 GROUP BY is_instant @@ -33,7 +33,7 @@ FULL OUTER JOIN ( is_instant , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_10 GROUP BY is_instant diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0.sql index 6f3082341a..323ea29003 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0_optimized.sql index cf47afc6bf..5ebe7177e8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Compute Metrics via Expressions SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -11,12 +11,12 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY subq_7.listing - , listings_latest_src_28005.country + , listings_latest_src_28000.country diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index f1535bf8d2..48ab8d3863 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -1,693 +1,693 @@ -- Compute Metrics via Expressions SELECT - subq_20.ds__day - , subq_20.listing__country_latest - , CAST(subq_20.bookings AS DOUBLE) / CAST(NULLIF(subq_20.views, 0) AS DOUBLE) AS bookings_per_view + subq_29.ds__day + , subq_29.listing__country_latest + , CAST(subq_29.bookings AS DOUBLE) / CAST(NULLIF(subq_29.views, 0) AS DOUBLE) AS bookings_per_view FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.ds__day, subq_19.ds__day) AS ds__day - , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) AS listing__country_latest - , MAX(subq_9.bookings) AS bookings - , MAX(subq_19.views) AS views + COALESCE(subq_18.ds__day, subq_28.ds__day) AS ds__day + , COALESCE(subq_18.listing__country_latest, subq_28.listing__country_latest) AS listing__country_latest + , MAX(subq_18.bookings) AS bookings + , MAX(subq_28.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_8.ds__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_17.ds__day + , subq_17.listing__country_latest + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.ds__day - , subq_7.listing__country_latest - , SUM(subq_7.bookings) AS bookings + subq_16.ds__day + , subq_16.listing__country_latest + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] SELECT - subq_6.ds__day - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.ds__day + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.listing AS listing - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.ds__day AS ds__day + , subq_11.listing AS listing + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] SELECT - subq_1.ds__day - , subq_1.listing - , subq_1.bookings + subq_10.ds__day + , subq_10.listing + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 GROUP BY - subq_7.ds__day - , subq_7.listing__country_latest - ) subq_8 - ) subq_9 + subq_16.ds__day + , subq_16.listing__country_latest + ) subq_17 + ) subq_18 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_18.ds__day - , subq_18.listing__country_latest - , subq_18.views + subq_27.ds__day + , subq_27.listing__country_latest + , subq_27.views FROM ( -- Aggregate Measures SELECT - subq_17.ds__day - , subq_17.listing__country_latest - , SUM(subq_17.views) AS views + subq_26.ds__day + , subq_26.listing__country_latest + , SUM(subq_26.views) AS views FROM ( -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] SELECT - subq_16.ds__day - , subq_16.listing__country_latest - , subq_16.views + subq_25.ds__day + , subq_25.listing__country_latest + , subq_25.views FROM ( -- Join Standard Outputs SELECT - subq_12.ds__day AS ds__day - , subq_12.listing AS listing - , subq_15.country_latest AS listing__country_latest - , subq_12.views AS views + subq_21.ds__day AS ds__day + , subq_21.listing AS listing + , subq_24.country_latest AS listing__country_latest + , subq_21.views AS views FROM ( -- Pass Only Elements: ['views', 'ds__day', 'listing'] SELECT - subq_11.ds__day - , subq_11.listing - , subq_11.views + subq_20.ds__day + , subq_20.listing + , subq_20.views 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.view__ds__day - , subq_10.view__ds__week - , subq_10.view__ds__month - , subq_10.view__ds__quarter - , subq_10.view__ds__year - , subq_10.view__ds__extract_year - , subq_10.view__ds__extract_quarter - , subq_10.view__ds__extract_month - , subq_10.view__ds__extract_day - , subq_10.view__ds__extract_dow - , subq_10.view__ds__extract_doy - , subq_10.view__ds_partitioned__day - , subq_10.view__ds_partitioned__week - , subq_10.view__ds_partitioned__month - , subq_10.view__ds_partitioned__quarter - , subq_10.view__ds_partitioned__year - , subq_10.view__ds_partitioned__extract_year - , subq_10.view__ds_partitioned__extract_quarter - , subq_10.view__ds_partitioned__extract_month - , subq_10.view__ds_partitioned__extract_day - , subq_10.view__ds_partitioned__extract_dow - , subq_10.view__ds_partitioned__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.view__listing - , subq_10.view__user - , subq_10.views + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.view__ds__day + , subq_19.view__ds__week + , subq_19.view__ds__month + , subq_19.view__ds__quarter + , subq_19.view__ds__year + , subq_19.view__ds__extract_year + , subq_19.view__ds__extract_quarter + , subq_19.view__ds__extract_month + , subq_19.view__ds__extract_day + , subq_19.view__ds__extract_dow + , subq_19.view__ds__extract_doy + , subq_19.view__ds_partitioned__day + , subq_19.view__ds_partitioned__week + , subq_19.view__ds_partitioned__month + , subq_19.view__ds_partitioned__quarter + , subq_19.view__ds_partitioned__year + , subq_19.view__ds_partitioned__extract_year + , subq_19.view__ds_partitioned__extract_quarter + , subq_19.view__ds_partitioned__extract_month + , subq_19.view__ds_partitioned__extract_day + , subq_19.view__ds_partitioned__extract_dow + , subq_19.view__ds_partitioned__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.user + , subq_19.view__listing + , subq_19.view__user + , subq_19.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , DATE_TRUNC('day', views_source_src_28010.ds) AS ds__day - , DATE_TRUNC('week', views_source_src_28010.ds) AS ds__week - , DATE_TRUNC('month', views_source_src_28010.ds) AS ds__month - , DATE_TRUNC('quarter', views_source_src_28010.ds) AS ds__quarter - , DATE_TRUNC('year', views_source_src_28010.ds) AS ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM views_source_src_28010.ds) AS ds__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds) AS ds__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', views_source_src_28010.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', views_source_src_28010.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_28010.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_28010.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds) AS view__ds__day - , DATE_TRUNC('week', views_source_src_28010.ds) AS view__ds__week - , DATE_TRUNC('month', views_source_src_28010.ds) AS view__ds__month - , DATE_TRUNC('quarter', views_source_src_28010.ds) AS view__ds__quarter - , DATE_TRUNC('year', views_source_src_28010.ds) AS view__ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS view__ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS view__ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS view__ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS view__ds__extract_day - , EXTRACT(dayofweekiso FROM views_source_src_28010.ds) AS view__ds__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds) AS view__ds__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__day - , DATE_TRUNC('week', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__week - , DATE_TRUNC('month', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_doy - , views_source_src_28010.listing_id AS listing - , views_source_src_28010.user_id AS user - , views_source_src_28010.listing_id AS view__listing - , views_source_src_28010.user_id AS view__user - FROM ***************************.fct_views views_source_src_28010 - ) subq_10 - ) subq_11 - ) subq_12 + , DATE_TRUNC('day', views_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', views_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', views_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', views_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', views_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM views_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', views_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', views_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds) AS view__ds__day + , DATE_TRUNC('week', views_source_src_28000.ds) AS view__ds__week + , DATE_TRUNC('month', views_source_src_28000.ds) AS view__ds__month + , DATE_TRUNC('quarter', views_source_src_28000.ds) AS view__ds__quarter + , DATE_TRUNC('year', views_source_src_28000.ds) AS view__ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS view__ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS view__ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS view__ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS view__ds__extract_day + , EXTRACT(dayofweekiso FROM views_source_src_28000.ds) AS view__ds__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds) AS view__ds__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__day + , DATE_TRUNC('week', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__week + , DATE_TRUNC('month', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_doy + , views_source_src_28000.listing_id AS listing + , views_source_src_28000.user_id AS user + , views_source_src_28000.listing_id AS view__listing + , views_source_src_28000.user_id AS view__user + FROM ***************************.fct_views views_source_src_28000 + ) subq_19 + ) subq_20 + ) subq_21 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_14.listing - , subq_14.country_latest + subq_23.listing + , subq_23.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_13.ds__day - , subq_13.ds__week - , subq_13.ds__month - , subq_13.ds__quarter - , subq_13.ds__year - , subq_13.ds__extract_year - , subq_13.ds__extract_quarter - , subq_13.ds__extract_month - , subq_13.ds__extract_day - , subq_13.ds__extract_dow - , subq_13.ds__extract_doy - , subq_13.created_at__day - , subq_13.created_at__week - , subq_13.created_at__month - , subq_13.created_at__quarter - , subq_13.created_at__year - , subq_13.created_at__extract_year - , subq_13.created_at__extract_quarter - , subq_13.created_at__extract_month - , subq_13.created_at__extract_day - , subq_13.created_at__extract_dow - , subq_13.created_at__extract_doy - , subq_13.listing__ds__day - , subq_13.listing__ds__week - , subq_13.listing__ds__month - , subq_13.listing__ds__quarter - , subq_13.listing__ds__year - , subq_13.listing__ds__extract_year - , subq_13.listing__ds__extract_quarter - , subq_13.listing__ds__extract_month - , subq_13.listing__ds__extract_day - , subq_13.listing__ds__extract_dow - , subq_13.listing__ds__extract_doy - , subq_13.listing__created_at__day - , subq_13.listing__created_at__week - , subq_13.listing__created_at__month - , subq_13.listing__created_at__quarter - , subq_13.listing__created_at__year - , subq_13.listing__created_at__extract_year - , subq_13.listing__created_at__extract_quarter - , subq_13.listing__created_at__extract_month - , subq_13.listing__created_at__extract_day - , subq_13.listing__created_at__extract_dow - , subq_13.listing__created_at__extract_doy - , subq_13.ds__day AS metric_time__day - , subq_13.ds__week AS metric_time__week - , subq_13.ds__month AS metric_time__month - , subq_13.ds__quarter AS metric_time__quarter - , subq_13.ds__year AS metric_time__year - , subq_13.ds__extract_year AS metric_time__extract_year - , subq_13.ds__extract_quarter AS metric_time__extract_quarter - , subq_13.ds__extract_month AS metric_time__extract_month - , subq_13.ds__extract_day AS metric_time__extract_day - , subq_13.ds__extract_dow AS metric_time__extract_dow - , subq_13.ds__extract_doy AS metric_time__extract_doy - , subq_13.listing - , subq_13.user - , subq_13.listing__user - , subq_13.country_latest - , subq_13.is_lux_latest - , subq_13.capacity_latest - , subq_13.listing__country_latest - , subq_13.listing__is_lux_latest - , subq_13.listing__capacity_latest - , subq_13.listings - , subq_13.largest_listing - , subq_13.smallest_listing + 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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_13 - ) subq_14 - ) subq_15 + , 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_22 + ) subq_23 + ) subq_24 ON - subq_12.listing = subq_15.listing - ) subq_16 - ) subq_17 + subq_21.listing = subq_24.listing + ) subq_25 + ) subq_26 GROUP BY - subq_17.ds__day - , subq_17.listing__country_latest - ) subq_18 - ) subq_19 + subq_26.ds__day + , subq_26.listing__country_latest + ) subq_27 + ) subq_28 ON ( - subq_9.listing__country_latest = subq_19.listing__country_latest + subq_18.listing__country_latest = subq_28.listing__country_latest ) AND ( - subq_9.ds__day = subq_19.ds__day + subq_18.ds__day = subq_28.ds__day ) GROUP BY - COALESCE(subq_9.ds__day, subq_19.ds__day) - , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) -) subq_20 + COALESCE(subq_18.ds__day, subq_28.ds__day) + , COALESCE(subq_18.listing__country_latest, subq_28.listing__country_latest) +) subq_29 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 5b65e65d85..75a09cbc63 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -6,19 +6,19 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest - , MAX(subq_30.bookings) AS bookings - , MAX(subq_40.views) AS views + COALESCE(subq_39.ds__day, subq_49.ds__day) AS ds__day + , COALESCE(subq_39.listing__country_latest, subq_49.listing__country_latest) AS listing__country_latest + , MAX(subq_39.bookings) AS bookings + , MAX(subq_49.views) AS views FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_23.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + subq_32.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_32.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -27,25 +27,25 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_23.listing = listings_latest_src_28005.listing_id + subq_32.listing = listings_latest_src_28000.listing_id GROUP BY - subq_23.ds__day - , listings_latest_src_28005.country - ) subq_30 + subq_32.ds__day + , listings_latest_src_28000.country + ) subq_39 FULL OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_33.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_33.views) AS views + subq_42.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_42.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' @@ -54,23 +54,23 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views - FROM ***************************.fct_views views_source_src_28010 - ) subq_33 + FROM ***************************.fct_views views_source_src_28000 + ) subq_42 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_33.listing = listings_latest_src_28005.listing_id + subq_42.listing = listings_latest_src_28000.listing_id GROUP BY - subq_33.ds__day - , listings_latest_src_28005.country - ) subq_40 + subq_42.ds__day + , listings_latest_src_28000.country + ) subq_49 ON ( - subq_30.listing__country_latest = subq_40.listing__country_latest + subq_39.listing__country_latest = subq_49.listing__country_latest ) AND ( - subq_30.ds__day = subq_40.ds__day + subq_39.ds__day = subq_49.ds__day ) GROUP BY - COALESCE(subq_30.ds__day, subq_40.ds__day) - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) -) subq_41 + COALESCE(subq_39.ds__day, subq_49.ds__day) + , COALESCE(subq_39.listing__country_latest, subq_49.listing__country_latest) +) subq_50 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 63a16e88aa..390392dacf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -28,93 +28,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql index 7c57c360fb..c943b1a8d9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Aggregate Measures SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings , COUNT(DISTINCT subq_7.bookers) AS bookers FROM ( @@ -18,13 +18,13 @@ FROM ( listing_id AS listing , 1 AS bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY subq_7.listing - , listings_latest_src_28005.country + , listings_latest_src_28000.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0.sql index d1ea5963e2..038022f027 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0_optimized.sql index 3bda7562bf..65e701e3dd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0_optimized.sql @@ -7,15 +7,15 @@ FROM ( -- Join Standard Outputs -- Aggregate Measures SELECT - bookings_source_src_28001.listing_id AS listing - , listings_latest_src_28005.country AS listing__country_latest - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.listing_id AS listing + , listings_latest_src_28000.country AS listing__country_latest + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY - bookings_source_src_28001.listing_id - , listings_latest_src_28005.country + bookings_source_src_28000.listing_id + , listings_latest_src_28000.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0.sql index 9b413ab923..09fc32dc6c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0_optimized.sql index db53f26587..d0d15f6943 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0_optimized.sql @@ -6,5 +6,5 @@ SELECT DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0.sql index 68e27b96e0..d1dedc82a3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -190,32 +190,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0_optimized.sql index 8cc8a2b867..c4e57d3c86 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,13 +5,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.country AS listing__country_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.country AS listing__country_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql index 2d95b7bd1e..651824a182 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql index bee3a232b6..96c5d5bb3a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY - listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_node__plan0.sql index 3c43a990ff..2e7a4c5fd0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_node__plan0.sql @@ -6,91 +6,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_node__plan0_optimized.sql index bfbf5ff951..554ce484fb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_node__plan0_optimized.sql @@ -2,4 +2,4 @@ -- Pass Only Elements: ['bookings',] SELECT 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0.sql index b982200696..01bfb0e712 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0_optimized.sql index 755a4d39e2..5ee87ba25f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0_optimized.sql @@ -8,6 +8,6 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_3 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index 6e3a76c40e..2689896e19 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index d5d4ba056e..6054b232dc 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0.sql index dd5074bc47..6fbac4ea91 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index cb1797bad8..61bc9299ec 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0.sql index 0b5d978d3f..43273b80a2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 695cf9c062..e4f47734b0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_aggregation_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_aggregation_node__plan0.sql index 3e74cf958d..1f8d370137 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_aggregation_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_aggregation_node__plan0.sql @@ -16,92 +16,92 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_aggregation_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_aggregation_node__plan0_optimized.sql index 64fc2826b9..6e5528a6c9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_aggregation_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_aggregation_node__plan0_optimized.sql @@ -6,4 +6,4 @@ SELECT , SUM(CASE WHEN is_instant THEN 1 ELSE 0 END) AS instant_bookings , COUNT(DISTINCT guest_id) AS bookers , AVG(booking_value) AS average_booking_value -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0.sql index 7b8e8ed9ed..4e470ff794 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0.sql @@ -14,93 +14,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -112,62 +112,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON @@ -181,62 +181,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0_optimized.sql index b9cecc48d8..7d9c669f54 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -18,7 +18,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_9 ON subq_7.listing = subq_9.listing @@ -28,7 +28,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_11 ON subq_7.listing = subq_11.listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0.sql index 645d50b2fc..3f77093112 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0.sql @@ -26,93 +26,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0_optimized.sql index fd8a1ff597..bcebfe9d5f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 GROUP BY ds__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0.sql index 53a5b7f6bd..c8bcda4fe4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -110,62 +110,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0_optimized.sql index e03ffcce64..a1cd7ac335 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_5.listing = listings_latest_src_28005.listing_id + subq_5.listing = listings_latest_src_28000.listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0.sql index 46563afc1f..b748a7e6cd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0.sql @@ -2,90 +2,90 @@ SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0_optimized.sql index f82aa0eaaf..69c345901c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0_optimized.sql @@ -88,4 +88,4 @@ SELECT , listing_id AS booking__listing , guest_id AS booking__guest , host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_combine_output_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_combine_output_node__plan0.sql index a276e77024..f999c0a475 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_combine_output_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_combine_output_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY @@ -128,93 +128,93 @@ FULL OUTER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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_3 ) subq_4 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_combine_output_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_combine_output_node__plan0_optimized.sql index a8375510d7..ad81788114 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_combine_output_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_combine_output_node__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( SELECT is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 GROUP BY is_instant @@ -33,7 +33,7 @@ FULL OUTER JOIN ( is_instant , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_10 GROUP BY is_instant diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node__plan0.sql index 36c720c533..169a72688a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node__plan0_optimized.sql index cf47afc6bf..5ebe7177e8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Compute Metrics via Expressions SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' @@ -11,12 +11,12 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY subq_7.listing - , listings_latest_src_28005.country + , listings_latest_src_28000.country diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 1b65412a32..e1b1aefa43 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -1,693 +1,693 @@ -- Compute Metrics via Expressions SELECT - subq_20.ds__day - , subq_20.listing__country_latest - , CAST(subq_20.bookings AS DOUBLE) / CAST(NULLIF(subq_20.views, 0) AS DOUBLE) AS bookings_per_view + subq_29.ds__day + , subq_29.listing__country_latest + , CAST(subq_29.bookings AS DOUBLE) / CAST(NULLIF(subq_29.views, 0) AS DOUBLE) AS bookings_per_view FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.ds__day, subq_19.ds__day) AS ds__day - , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) AS listing__country_latest - , MAX(subq_9.bookings) AS bookings - , MAX(subq_19.views) AS views + COALESCE(subq_18.ds__day, subq_28.ds__day) AS ds__day + , COALESCE(subq_18.listing__country_latest, subq_28.listing__country_latest) AS listing__country_latest + , MAX(subq_18.bookings) AS bookings + , MAX(subq_28.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_8.ds__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_17.ds__day + , subq_17.listing__country_latest + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.ds__day - , subq_7.listing__country_latest - , SUM(subq_7.bookings) AS bookings + subq_16.ds__day + , subq_16.listing__country_latest + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] SELECT - subq_6.ds__day - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.ds__day + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.listing AS listing - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.ds__day AS ds__day + , subq_11.listing AS listing + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] SELECT - subq_1.ds__day - , subq_1.listing - , subq_1.bookings + subq_10.ds__day + , subq_10.listing + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 GROUP BY - subq_7.ds__day - , subq_7.listing__country_latest - ) subq_8 - ) subq_9 + subq_16.ds__day + , subq_16.listing__country_latest + ) subq_17 + ) subq_18 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_18.ds__day - , subq_18.listing__country_latest - , subq_18.views + subq_27.ds__day + , subq_27.listing__country_latest + , subq_27.views FROM ( -- Aggregate Measures SELECT - subq_17.ds__day - , subq_17.listing__country_latest - , SUM(subq_17.views) AS views + subq_26.ds__day + , subq_26.listing__country_latest + , SUM(subq_26.views) AS views FROM ( -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] SELECT - subq_16.ds__day - , subq_16.listing__country_latest - , subq_16.views + subq_25.ds__day + , subq_25.listing__country_latest + , subq_25.views FROM ( -- Join Standard Outputs SELECT - subq_12.ds__day AS ds__day - , subq_12.listing AS listing - , subq_15.country_latest AS listing__country_latest - , subq_12.views AS views + subq_21.ds__day AS ds__day + , subq_21.listing AS listing + , subq_24.country_latest AS listing__country_latest + , subq_21.views AS views FROM ( -- Pass Only Elements: ['views', 'ds__day', 'listing'] SELECT - subq_11.ds__day - , subq_11.listing - , subq_11.views + subq_20.ds__day + , subq_20.listing + , subq_20.views 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.view__ds__day - , subq_10.view__ds__week - , subq_10.view__ds__month - , subq_10.view__ds__quarter - , subq_10.view__ds__year - , subq_10.view__ds__extract_year - , subq_10.view__ds__extract_quarter - , subq_10.view__ds__extract_month - , subq_10.view__ds__extract_day - , subq_10.view__ds__extract_dow - , subq_10.view__ds__extract_doy - , subq_10.view__ds_partitioned__day - , subq_10.view__ds_partitioned__week - , subq_10.view__ds_partitioned__month - , subq_10.view__ds_partitioned__quarter - , subq_10.view__ds_partitioned__year - , subq_10.view__ds_partitioned__extract_year - , subq_10.view__ds_partitioned__extract_quarter - , subq_10.view__ds_partitioned__extract_month - , subq_10.view__ds_partitioned__extract_day - , subq_10.view__ds_partitioned__extract_dow - , subq_10.view__ds_partitioned__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.view__listing - , subq_10.view__user - , subq_10.views + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.view__ds__day + , subq_19.view__ds__week + , subq_19.view__ds__month + , subq_19.view__ds__quarter + , subq_19.view__ds__year + , subq_19.view__ds__extract_year + , subq_19.view__ds__extract_quarter + , subq_19.view__ds__extract_month + , subq_19.view__ds__extract_day + , subq_19.view__ds__extract_dow + , subq_19.view__ds__extract_doy + , subq_19.view__ds_partitioned__day + , subq_19.view__ds_partitioned__week + , subq_19.view__ds_partitioned__month + , subq_19.view__ds_partitioned__quarter + , subq_19.view__ds_partitioned__year + , subq_19.view__ds_partitioned__extract_year + , subq_19.view__ds_partitioned__extract_quarter + , subq_19.view__ds_partitioned__extract_month + , subq_19.view__ds_partitioned__extract_day + , subq_19.view__ds_partitioned__extract_dow + , subq_19.view__ds_partitioned__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.user + , subq_19.view__listing + , subq_19.view__user + , subq_19.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , DATE_TRUNC('day', views_source_src_28010.ds) AS ds__day - , DATE_TRUNC('week', views_source_src_28010.ds) AS ds__week - , DATE_TRUNC('month', views_source_src_28010.ds) AS ds__month - , DATE_TRUNC('quarter', views_source_src_28010.ds) AS ds__quarter - , DATE_TRUNC('year', views_source_src_28010.ds) AS ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM views_source_src_28010.ds) AS ds__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds) AS ds__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', views_source_src_28010.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', views_source_src_28010.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_28010.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_28010.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds) AS view__ds__day - , DATE_TRUNC('week', views_source_src_28010.ds) AS view__ds__week - , DATE_TRUNC('month', views_source_src_28010.ds) AS view__ds__month - , DATE_TRUNC('quarter', views_source_src_28010.ds) AS view__ds__quarter - , DATE_TRUNC('year', views_source_src_28010.ds) AS view__ds__year - , EXTRACT(year FROM views_source_src_28010.ds) AS view__ds__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds) AS view__ds__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds) AS view__ds__extract_month - , EXTRACT(day FROM views_source_src_28010.ds) AS view__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM views_source_src_28010.ds) AS view__ds__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds) AS view__ds__extract_doy - , DATE_TRUNC('day', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__day - , DATE_TRUNC('week', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__week - , DATE_TRUNC('month', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__month - , DATE_TRUNC('quarter', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__quarter - , DATE_TRUNC('year', views_source_src_28010.ds_partitioned) AS view__ds_partitioned__year - , EXTRACT(year FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_year - , EXTRACT(quarter FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_quarter - , EXTRACT(month FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_month - , EXTRACT(day FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_dow - , EXTRACT(doy FROM views_source_src_28010.ds_partitioned) AS view__ds_partitioned__extract_doy - , views_source_src_28010.listing_id AS listing - , views_source_src_28010.user_id AS user - , views_source_src_28010.listing_id AS view__listing - , views_source_src_28010.user_id AS view__user - FROM ***************************.fct_views views_source_src_28010 - ) subq_10 - ) subq_11 - ) subq_12 + , DATE_TRUNC('day', views_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', views_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', views_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', views_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', views_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM views_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', views_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', views_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds) AS view__ds__day + , DATE_TRUNC('week', views_source_src_28000.ds) AS view__ds__week + , DATE_TRUNC('month', views_source_src_28000.ds) AS view__ds__month + , DATE_TRUNC('quarter', views_source_src_28000.ds) AS view__ds__quarter + , DATE_TRUNC('year', views_source_src_28000.ds) AS view__ds__year + , EXTRACT(year FROM views_source_src_28000.ds) AS view__ds__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds) AS view__ds__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds) AS view__ds__extract_month + , EXTRACT(day FROM views_source_src_28000.ds) AS view__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM views_source_src_28000.ds) AS view__ds__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds) AS view__ds__extract_doy + , DATE_TRUNC('day', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__day + , DATE_TRUNC('week', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__week + , DATE_TRUNC('month', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__month + , DATE_TRUNC('quarter', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__quarter + , DATE_TRUNC('year', views_source_src_28000.ds_partitioned) AS view__ds_partitioned__year + , EXTRACT(year FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_year + , EXTRACT(quarter FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_quarter + , EXTRACT(month FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_month + , EXTRACT(day FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_dow + , EXTRACT(doy FROM views_source_src_28000.ds_partitioned) AS view__ds_partitioned__extract_doy + , views_source_src_28000.listing_id AS listing + , views_source_src_28000.user_id AS user + , views_source_src_28000.listing_id AS view__listing + , views_source_src_28000.user_id AS view__user + FROM ***************************.fct_views views_source_src_28000 + ) subq_19 + ) subq_20 + ) subq_21 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_14.listing - , subq_14.country_latest + subq_23.listing + , subq_23.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_13.ds__day - , subq_13.ds__week - , subq_13.ds__month - , subq_13.ds__quarter - , subq_13.ds__year - , subq_13.ds__extract_year - , subq_13.ds__extract_quarter - , subq_13.ds__extract_month - , subq_13.ds__extract_day - , subq_13.ds__extract_dow - , subq_13.ds__extract_doy - , subq_13.created_at__day - , subq_13.created_at__week - , subq_13.created_at__month - , subq_13.created_at__quarter - , subq_13.created_at__year - , subq_13.created_at__extract_year - , subq_13.created_at__extract_quarter - , subq_13.created_at__extract_month - , subq_13.created_at__extract_day - , subq_13.created_at__extract_dow - , subq_13.created_at__extract_doy - , subq_13.listing__ds__day - , subq_13.listing__ds__week - , subq_13.listing__ds__month - , subq_13.listing__ds__quarter - , subq_13.listing__ds__year - , subq_13.listing__ds__extract_year - , subq_13.listing__ds__extract_quarter - , subq_13.listing__ds__extract_month - , subq_13.listing__ds__extract_day - , subq_13.listing__ds__extract_dow - , subq_13.listing__ds__extract_doy - , subq_13.listing__created_at__day - , subq_13.listing__created_at__week - , subq_13.listing__created_at__month - , subq_13.listing__created_at__quarter - , subq_13.listing__created_at__year - , subq_13.listing__created_at__extract_year - , subq_13.listing__created_at__extract_quarter - , subq_13.listing__created_at__extract_month - , subq_13.listing__created_at__extract_day - , subq_13.listing__created_at__extract_dow - , subq_13.listing__created_at__extract_doy - , subq_13.ds__day AS metric_time__day - , subq_13.ds__week AS metric_time__week - , subq_13.ds__month AS metric_time__month - , subq_13.ds__quarter AS metric_time__quarter - , subq_13.ds__year AS metric_time__year - , subq_13.ds__extract_year AS metric_time__extract_year - , subq_13.ds__extract_quarter AS metric_time__extract_quarter - , subq_13.ds__extract_month AS metric_time__extract_month - , subq_13.ds__extract_day AS metric_time__extract_day - , subq_13.ds__extract_dow AS metric_time__extract_dow - , subq_13.ds__extract_doy AS metric_time__extract_doy - , subq_13.listing - , subq_13.user - , subq_13.listing__user - , subq_13.country_latest - , subq_13.is_lux_latest - , subq_13.capacity_latest - , subq_13.listing__country_latest - , subq_13.listing__is_lux_latest - , subq_13.listing__capacity_latest - , subq_13.listings - , subq_13.largest_listing - , subq_13.smallest_listing + 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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_13 - ) subq_14 - ) subq_15 + , 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_22 + ) subq_23 + ) subq_24 ON - subq_12.listing = subq_15.listing - ) subq_16 - ) subq_17 + subq_21.listing = subq_24.listing + ) subq_25 + ) subq_26 GROUP BY - subq_17.ds__day - , subq_17.listing__country_latest - ) subq_18 - ) subq_19 + subq_26.ds__day + , subq_26.listing__country_latest + ) subq_27 + ) subq_28 ON ( - subq_9.listing__country_latest = subq_19.listing__country_latest + subq_18.listing__country_latest = subq_28.listing__country_latest ) AND ( - subq_9.ds__day = subq_19.ds__day + subq_18.ds__day = subq_28.ds__day ) GROUP BY - COALESCE(subq_9.ds__day, subq_19.ds__day) - , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) -) subq_20 + COALESCE(subq_18.ds__day, subq_28.ds__day) + , COALESCE(subq_18.listing__country_latest, subq_28.listing__country_latest) +) subq_29 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 5b65e65d85..75a09cbc63 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -6,19 +6,19 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest - , MAX(subq_30.bookings) AS bookings - , MAX(subq_40.views) AS views + COALESCE(subq_39.ds__day, subq_49.ds__day) AS ds__day + , COALESCE(subq_39.listing__country_latest, subq_49.listing__country_latest) AS listing__country_latest + , MAX(subq_39.bookings) AS bookings + , MAX(subq_49.views) AS views FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_23.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + subq_32.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_32.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -27,25 +27,25 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_23.listing = listings_latest_src_28005.listing_id + subq_32.listing = listings_latest_src_28000.listing_id GROUP BY - subq_23.ds__day - , listings_latest_src_28005.country - ) subq_30 + subq_32.ds__day + , listings_latest_src_28000.country + ) subq_39 FULL OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['views', 'listing__country_latest', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_33.ds__day AS ds__day - , listings_latest_src_28005.country AS listing__country_latest - , SUM(subq_33.views) AS views + subq_42.ds__day AS ds__day + , listings_latest_src_28000.country AS listing__country_latest + , SUM(subq_42.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' @@ -54,23 +54,23 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views - FROM ***************************.fct_views views_source_src_28010 - ) subq_33 + FROM ***************************.fct_views views_source_src_28000 + ) subq_42 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_33.listing = listings_latest_src_28005.listing_id + subq_42.listing = listings_latest_src_28000.listing_id GROUP BY - subq_33.ds__day - , listings_latest_src_28005.country - ) subq_40 + subq_42.ds__day + , listings_latest_src_28000.country + ) subq_49 ON ( - subq_30.listing__country_latest = subq_40.listing__country_latest + subq_39.listing__country_latest = subq_49.listing__country_latest ) AND ( - subq_30.ds__day = subq_40.ds__day + subq_39.ds__day = subq_49.ds__day ) GROUP BY - COALESCE(subq_30.ds__day, subq_40.ds__day) - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) -) subq_41 + COALESCE(subq_39.ds__day, subq_49.ds__day) + , COALESCE(subq_39.listing__country_latest, subq_49.listing__country_latest) +) subq_50 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 812ca8344a..c2f25848d4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -28,93 +28,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql index 7c57c360fb..c943b1a8d9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_single_semantic_model__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Aggregate Measures SELECT subq_7.listing AS listing - , listings_latest_src_28005.country AS listing__country_latest + , listings_latest_src_28000.country AS listing__country_latest , SUM(subq_7.bookings) AS bookings , COUNT(DISTINCT subq_7.bookers) AS bookers FROM ( @@ -18,13 +18,13 @@ FROM ( listing_id AS listing , 1 AS bookings , guest_id AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_7.listing = listings_latest_src_28005.listing_id + subq_7.listing = listings_latest_src_28000.listing_id GROUP BY subq_7.listing - , listings_latest_src_28005.country + , listings_latest_src_28000.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_simple_expr__plan0.sql index 2bd5c9d86e..1d72a8ab11 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_simple_expr__plan0.sql @@ -25,93 +25,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -123,62 +123,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_simple_expr__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_simple_expr__plan0_optimized.sql index 3bda7562bf..65e701e3dd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_simple_expr__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_simple_expr__plan0_optimized.sql @@ -7,15 +7,15 @@ FROM ( -- Join Standard Outputs -- Aggregate Measures SELECT - bookings_source_src_28001.listing_id AS listing - , listings_latest_src_28005.country AS listing__country_latest - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.listing_id AS listing + , listings_latest_src_28000.country AS listing__country_latest + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY - bookings_source_src_28001.listing_id - , listings_latest_src_28005.country + bookings_source_src_28000.listing_id + , listings_latest_src_28000.country ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0.sql index bba1d890d8..21d79f30ae 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0.sql @@ -19,93 +19,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0_optimized.sql index b8eb96e8e9..137bae5f65 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_constrain_time_range_node__plan0_optimized.sql @@ -6,5 +6,5 @@ SELECT DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0.sql index 9bf2a562f5..c30f2c64e7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0.sql @@ -125,62 +125,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -190,32 +190,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0_optimized.sql index 8cc8a2b867..c4e57d3c86 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,13 +5,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.country AS listing__country_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.country AS listing__country_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0.sql index 9dea907a17..28f04502f2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0_optimized.sql index bee3a232b6..96c5d5bb3a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY - listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_node__plan0.sql index 27231f192b..8b3794a47b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_node__plan0.sql @@ -6,91 +6,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_node__plan0_optimized.sql index bfbf5ff951..554ce484fb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_node__plan0_optimized.sql @@ -2,4 +2,4 @@ -- Pass Only Elements: ['bookings',] SELECT 1 AS bookings -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_node__plan0.sql index a0f5744171..29197c39d7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_node__plan0_optimized.sql index 755a4d39e2..5ee87ba25f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_node__plan0_optimized.sql @@ -8,6 +8,6 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_3 WHERE booking__ds__day = '2020-01-01' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index ec47dfdc83..e8a3b24016 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index 55f87d10bc..dfbf45320a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0.sql index 079efbd3b0..02c8875b37 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index 1219f9e494..46290a43a2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0.sql index 3cd1a50096..a6b2e3622c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0.sql @@ -134,93 +134,93 @@ INNER JOIN ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 8ea0c288dc..079f6f5209 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -25,7 +25,7 @@ INNER JOIN ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) , listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_measure_aggregation_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_measure_aggregation_node__plan0.sql index dba9ded776..a2fc874608 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_measure_aggregation_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_measure_aggregation_node__plan0.sql @@ -16,92 +16,92 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_measure_aggregation_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_measure_aggregation_node__plan0_optimized.sql index 64fc2826b9..6e5528a6c9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_measure_aggregation_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_measure_aggregation_node__plan0_optimized.sql @@ -6,4 +6,4 @@ SELECT , SUM(CASE WHEN is_instant THEN 1 ELSE 0 END) AS instant_bookings , COUNT(DISTINCT guest_id) AS bookers , AVG(booking_value) AS average_booking_value -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multi_join_node__plan0.sql index 679926be9f..bf4d3b9719 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multi_join_node__plan0.sql @@ -14,93 +14,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -112,62 +112,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON @@ -181,62 +181,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_4 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multi_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multi_join_node__plan0_optimized.sql index b9cecc48d8..7d9c669f54 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multi_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_multi_join_node__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_7 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -18,7 +18,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_9 ON subq_7.listing = subq_9.listing @@ -28,7 +28,7 @@ LEFT OUTER JOIN ( SELECT listing_id AS listing , country AS country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_11 ON subq_7.listing = subq_11.listing diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_order_by_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_order_by_node__plan0.sql index f77b20ceac..b06170c5ce 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_order_by_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_order_by_node__plan0.sql @@ -26,93 +26,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_order_by_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_order_by_node__plan0_optimized.sql index fd8a1ff597..bcebfe9d5f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_order_by_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_order_by_node__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( DATE_TRUNC('day', ds) AS ds__day , is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 GROUP BY ds__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_single_join_node__plan0.sql index ffd4bbce0f..15bec31d75 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_single_join_node__plan0.sql @@ -12,93 +12,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 LEFT OUTER JOIN ( @@ -110,62 +110,62 @@ LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_single_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_single_join_node__plan0_optimized.sql index e03ffcce64..a1cd7ac335 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_single_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_single_join_node__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( SELECT listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_5 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_5.listing = listings_latest_src_28005.listing_id + subq_5.listing = listings_latest_src_28000.listing_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_source_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_source_node__plan0.sql index 29278dc9f7..cf384bbdbe 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_source_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_source_node__plan0.sql @@ -2,90 +2,90 @@ SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_source_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_source_node__plan0_optimized.sql index eb73e0c58e..1ee93a834a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_source_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_source_node__plan0_optimized.sql @@ -88,4 +88,4 @@ SELECT , listing_id AS booking__listing , guest_id AS booking__guest , host_id AS booking__host -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml index 61f123ca07..53634d56af 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml @@ -36,7 +36,7 @@ - + @@ -132,7 +132,7 @@ - + @@ -1845,7 +1845,7 @@ - + diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index f4d266a946..38ae05a24f 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -1,441 +1,441 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.bookers AS every_2_days_bookers_2_days_ago + subq_19.metric_time__day + , subq_19.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , COUNT(DISTINCT subq_9.bookers) AS bookers + subq_18.metric_time__day + , COUNT(DISTINCT subq_18.bookers) AS bookers FROM ( -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] SELECT - subq_8.metric_time__day - , subq_8.bookers + subq_17.metric_time__day + , subq_17.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 2 day) + subq_10.metric_time__day > DATE_SUB(CAST(subq_11.metric_time__day AS DATETIME), INTERVAL 2 day) ) - ) subq_4 + ) subq_13 ON - DATE_SUB(CAST(subq_5.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_4.metric_time__day - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_9 + DATE_SUB(CAST(subq_14.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_13.metric_time__day + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_18 GROUP BY metric_time__day - ) subq_10 -) subq_11 + ) subq_19 +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index 8017ba04bd..5293e2c548 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -9,33 +9,33 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day AS metric_time__day - , COUNT(DISTINCT subq_16.bookers) AS every_2_days_bookers_2_days_ago + subq_26.metric_time__day AS metric_time__day + , COUNT(DISTINCT subq_25.bookers) AS every_2_days_bookers_2_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_18 + FROM ***************************.mf_time_spine subq_27 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_17 + ) subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_15.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_24 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC(bookings_source_src_28001.ds, day) <= subq_15.ds + DATE_TRUNC(bookings_source_src_28000.ds, day) <= subq_24.ds ) AND ( - DATE_TRUNC(bookings_source_src_28001.ds, day) > DATE_SUB(CAST(subq_15.ds AS DATETIME), INTERVAL 2 day) + DATE_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_24.ds AS DATETIME), INTERVAL 2 day) ) - ) subq_16 + ) subq_25 ON - DATE_SUB(CAST(subq_17.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_16.metric_time__day - WHERE subq_17.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' + DATE_SUB(CAST(subq_26.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_25.metric_time__day + WHERE subq_26.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' GROUP BY metric_time__day -) subq_23 +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0.sql index 13d7c71960..837ef0b791 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0.sql @@ -1,445 +1,445 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__day - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY metric_time__day - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY metric_time__day -) subq_10 +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0_optimized.sql index 96c7f9893d..835463ceca 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , MAX(subq_15.ref_bookings) AS ref_bookings - , MAX(subq_20.bookings) AS bookings + COALESCE(subq_24.metric_time__day, subq_29.metric_time__day) AS metric_time__day + , MAX(subq_24.ref_bookings) AS ref_bookings + , MAX(subq_29.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,11 +21,11 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 GROUP BY metric_time__day - ) subq_15 + ) subq_24 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,13 +39,13 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_15.metric_time__day = subq_20.metric_time__day + subq_24.metric_time__day = subq_29.metric_time__day GROUP BY metric_time__day -) subq_21 +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 0de5b54144..aa452a5243 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -1,73 +1,73 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__month + subq_9.metric_time__month , bookings_last_month AS bookings_last_month FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly AS bookings_last_month + subq_8.metric_time__month + , subq_8.bookings_monthly AS bookings_last_month FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__month - , SUM(subq_5.bookings_monthly) AS bookings_monthly + subq_7.metric_time__month + , SUM(subq_7.bookings_monthly) AS bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_4.metric_time__month - , subq_4.bookings_monthly + subq_6.metric_time__month + , subq_6.bookings_monthly FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__month AS metric_time__month - , subq_1.monthly_ds__month AS monthly_ds__month - , subq_1.monthly_ds__quarter AS monthly_ds__quarter - , subq_1.monthly_ds__year AS monthly_ds__year - , subq_1.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_1.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_1.listing AS listing - , subq_1.booking__listing AS booking__listing - , subq_1.bookings_monthly AS bookings_monthly + subq_4.metric_time__month AS metric_time__month + , subq_3.monthly_ds__month AS monthly_ds__month + , subq_3.monthly_ds__quarter AS monthly_ds__quarter + , subq_3.monthly_ds__year AS monthly_ds__year + , subq_3.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_3.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_3.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_3.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_3.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_3.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_3.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_3.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_3.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_3.listing AS listing + , subq_3.booking__listing AS booking__listing + , subq_3.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC(subq_3.ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_3 + DATE_TRUNC(subq_5.ds, month) AS metric_time__month + FROM ***************************.mf_time_spine subq_5 GROUP BY metric_time__month - ) subq_2 + ) subq_4 INNER JOIN ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_2.monthly_ds__month + , subq_2.monthly_ds__quarter + , subq_2.monthly_ds__year + , subq_2.monthly_ds__extract_year + , subq_2.monthly_ds__extract_quarter + , subq_2.monthly_ds__extract_month + , subq_2.booking__monthly_ds__month + , subq_2.booking__monthly_ds__quarter + , subq_2.booking__monthly_ds__year + , subq_2.booking__monthly_ds__extract_year + , subq_2.booking__monthly_ds__extract_quarter + , subq_2.booking__monthly_ds__extract_month + , subq_2.monthly_ds__month AS metric_time__month + , subq_2.monthly_ds__quarter AS metric_time__quarter + , subq_2.monthly_ds__year AS metric_time__year + , subq_2.monthly_ds__extract_year AS metric_time__extract_year + , subq_2.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_2.monthly_ds__extract_month AS metric_time__extract_month + , subq_2.listing + , subq_2.booking__listing + , subq_2.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -87,13 +87,13 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 + ) subq_2 + ) subq_3 ON - DATE_SUB(CAST(subq_2.metric_time__month AS DATETIME), INTERVAL 1 month) = subq_1.metric_time__month - ) subq_4 - ) subq_5 + DATE_SUB(CAST(subq_4.metric_time__month AS DATETIME), INTERVAL 1 month) = subq_3.metric_time__month + ) subq_6 + ) subq_7 GROUP BY metric_time__month - ) subq_6 -) subq_7 + ) subq_8 +) subq_9 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index 5d3bd940a3..abaab21353 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -8,20 +8,20 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month AS metric_time__month + subq_12.metric_time__month AS metric_time__month , SUM(bookings_monthly_source_src_16000.bookings_monthly) AS bookings_last_month FROM ( -- Time Spine SELECT DATE_TRUNC(ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_13 GROUP BY metric_time__month - ) subq_10 + ) subq_12 INNER JOIN ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 ON - DATE_SUB(CAST(subq_10.metric_time__month AS DATETIME), INTERVAL 1 month) = DATE_TRUNC(bookings_monthly_source_src_16000.ds, month) + DATE_SUB(CAST(subq_12.metric_time__month AS DATETIME), INTERVAL 1 month) = DATE_TRUNC(bookings_monthly_source_src_16000.ds, month) GROUP BY metric_time__month -) subq_15 +) subq_17 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql index fea9961fc7..9d7e760a01 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__day - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC(subq_7.metric_time__day, month) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC(subq_16.metric_time__day, month) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY metric_time__day - ) subq_11 - ) subq_12 + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY metric_time__day -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index d37df9cff5..4a45e241b2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC(subq_22.ds, month) = subq_20.metric_time__day + DATE_TRUNC(subq_31.ds, month) = subq_29.metric_time__day GROUP BY metric_time__day - ) subq_26 + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY metric_time__day -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index 06c13a54dd..25259dbe96 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -1,546 +1,546 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__week + subq_22.metric_time__week , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) AS metric_time__week - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__week, subq_21.metric_time__week) AS metric_time__week + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__week - , subq_3.bookings + subq_12.metric_time__week + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__week - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__week + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_1.metric_time__week - , subq_1.bookings + subq_10.metric_time__week + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__week - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__week - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__week + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__week - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__week + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_9.metric_time__week - , subq_9.bookings + subq_18.metric_time__week + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC(subq_7.metric_time__day, isoweek) AS metric_time__week - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC(subq_16.metric_time__day, isoweek) AS metric_time__week + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC(subq_7.metric_time__day, month) = subq_6.metric_time__day - WHERE DATE_TRUNC(subq_7.metric_time__day, isoweek) = subq_7.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC(subq_16.metric_time__day, month) = subq_15.metric_time__day + WHERE DATE_TRUNC(subq_16.metric_time__day, isoweek) = subq_16.metric_time__day + ) subq_18 + ) subq_19 GROUP BY metric_time__week - ) subq_11 - ) subq_12 + ) subq_20 + ) subq_21 ON - subq_4.metric_time__week = subq_12.metric_time__week + subq_13.metric_time__week = subq_21.metric_time__week GROUP BY metric_time__week -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index 5deccf14fa..66fdf4eff2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) AS metric_time__week - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__week, subq_35.metric_time__week) AS metric_time__week + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,36 +21,36 @@ FROM ( SELECT DATE_TRUNC(ds, isoweek) AS metric_time__week , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__week - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__week'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC(subq_22.ds, isoweek) AS metric_time__week - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC(subq_31.ds, isoweek) AS metric_time__week + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC(subq_22.ds, month) = subq_20.metric_time__day - WHERE DATE_TRUNC(subq_22.ds, isoweek) = subq_22.ds + DATE_TRUNC(subq_31.ds, month) = subq_29.metric_time__day + WHERE DATE_TRUNC(subq_31.ds, isoweek) = subq_31.ds GROUP BY metric_time__week - ) subq_26 + ) subq_35 ON - subq_18.metric_time__week = subq_26.metric_time__week + subq_27.metric_time__week = subq_35.metric_time__week GROUP BY metric_time__week -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql index c16f9d3134..26044e5ad2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__day - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_SUB(CAST(subq_7.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATE_SUB(CAST(subq_16.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY metric_time__day - ) subq_11 - ) subq_12 + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY metric_time__day -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql index 8fa70fcf9d..2b2ce7a0e0 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_SUB(CAST(subq_22.ds AS DATETIME), INTERVAL 14 day) = subq_20.metric_time__day + DATE_SUB(CAST(subq_31.ds AS DATETIME), INTERVAL 14 day) = subq_29.metric_time__day GROUP BY metric_time__day - ) subq_26 + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY metric_time__day -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 0b17b0c775..a9a7d2730a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__quarter + subq_22.metric_time__quarter , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) AS metric_time__quarter - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__quarter, subq_21.metric_time__quarter) AS metric_time__quarter + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__quarter - , subq_3.bookings + subq_12.metric_time__quarter + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__quarter - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__quarter + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_1.metric_time__quarter - , subq_1.bookings + subq_10.metric_time__quarter + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__quarter - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__quarter - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__quarter + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__quarter - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__quarter + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_9.metric_time__quarter - , subq_9.bookings + subq_18.metric_time__quarter + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC(subq_7.metric_time__day, quarter) AS metric_time__quarter - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC(subq_16.metric_time__day, quarter) AS metric_time__quarter + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_SUB(CAST(subq_7.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATE_SUB(CAST(subq_16.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY metric_time__quarter - ) subq_11 - ) subq_12 + ) subq_20 + ) subq_21 ON - subq_4.metric_time__quarter = subq_12.metric_time__quarter + subq_13.metric_time__quarter = subq_21.metric_time__quarter GROUP BY metric_time__quarter -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index d826bdbd46..3aa56a19b3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) AS metric_time__quarter - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__quarter, subq_35.metric_time__quarter) AS metric_time__quarter + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC(ds, quarter) AS metric_time__quarter , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__quarter - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__quarter'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC(subq_22.ds, quarter) AS metric_time__quarter - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC(subq_31.ds, quarter) AS metric_time__quarter + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_SUB(CAST(subq_22.ds AS DATETIME), INTERVAL 14 day) = subq_20.metric_time__day + DATE_SUB(CAST(subq_31.ds AS DATETIME), INTERVAL 14 day) = subq_29.metric_time__day GROUP BY metric_time__quarter - ) subq_26 + ) subq_35 ON - subq_18.metric_time__quarter = subq_26.metric_time__quarter + subq_27.metric_time__quarter = subq_35.metric_time__quarter GROUP BY metric_time__quarter -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 9afd2673b1..06729b6831 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -1,645 +1,645 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__day + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC(subq_2.metric_time__day, month) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC(subq_11.metric_time__day, month) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY metric_time__day - ) subq_6 - ) subq_7 + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATE_SUB(CAST(subq_10.metric_time__day AS DATETIME), INTERVAL 1 month) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATE_SUB(CAST(subq_19.metric_time__day AS DATETIME), INTERVAL 1 month) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY metric_time__day - ) subq_14 - ) subq_15 + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY metric_time__day -) subq_16 +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 1d68b2b651..4a04ab6bbb 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -5,55 +5,55 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_20.ds AS metric_time__day - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + subq_29.ds AS metric_time__day + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC(subq_20.ds, month) = subq_18.metric_time__day + DATE_TRUNC(subq_29.ds, month) = subq_27.metric_time__day GROUP BY metric_time__day - ) subq_24 + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATE_SUB(CAST(subq_28.ds AS DATETIME), INTERVAL 1 month) = subq_26.metric_time__day + DATE_SUB(CAST(subq_37.ds AS DATETIME), INTERVAL 1 month) = subq_35.metric_time__day GROUP BY metric_time__day - ) subq_32 + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY metric_time__day -) subq_33 +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 8bd8d05233..ca230b4854 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -1,646 +1,646 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__year + subq_25.metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) AS metric_time__year - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__year, subq_24.metric_time__year) AS metric_time__year + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__year - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__year + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__year - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__year + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_4.metric_time__year - , subq_4.bookings + subq_13.metric_time__year + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC(subq_2.metric_time__day, year) AS metric_time__year - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC(subq_11.metric_time__day, year) AS metric_time__year + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC(subq_2.metric_time__day, month) = subq_1.metric_time__day - WHERE DATE_TRUNC(subq_2.metric_time__day, year) = subq_2.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC(subq_11.metric_time__day, month) = subq_10.metric_time__day + WHERE DATE_TRUNC(subq_11.metric_time__day, year) = subq_11.metric_time__day + ) subq_13 + ) subq_14 GROUP BY metric_time__year - ) subq_6 - ) subq_7 + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__year - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__year + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__year - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__year + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_12.metric_time__year - , subq_12.bookings + subq_21.metric_time__year + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC(subq_10.metric_time__day, year) AS metric_time__year - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC(subq_19.metric_time__day, year) AS metric_time__year + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATE_SUB(CAST(subq_10.metric_time__day AS DATETIME), INTERVAL 1 month) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATE_SUB(CAST(subq_19.metric_time__day AS DATETIME), INTERVAL 1 month) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY metric_time__year - ) subq_14 - ) subq_15 + ) subq_23 + ) subq_24 ON - subq_7.metric_time__year = subq_15.metric_time__year + subq_16.metric_time__year = subq_24.metric_time__year GROUP BY metric_time__year -) subq_16 +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 48eb4e3434..ef8c58c1ce 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,56 +5,56 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) AS metric_time__year - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__year, subq_41.metric_time__year) AS metric_time__year + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC(subq_20.ds, year) AS metric_time__year - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + DATE_TRUNC(subq_29.ds, year) AS metric_time__year + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC(subq_20.ds, month) = subq_18.metric_time__day - WHERE DATE_TRUNC(subq_20.ds, year) = subq_20.ds + DATE_TRUNC(subq_29.ds, month) = subq_27.metric_time__day + WHERE DATE_TRUNC(subq_29.ds, year) = subq_29.ds GROUP BY metric_time__year - ) subq_24 + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC(subq_28.ds, year) AS metric_time__year - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + DATE_TRUNC(subq_37.ds, year) AS metric_time__year + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATE_SUB(CAST(subq_28.ds AS DATETIME), INTERVAL 1 month) = subq_26.metric_time__day + DATE_SUB(CAST(subq_37.ds AS DATETIME), INTERVAL 1 month) = subq_35.metric_time__day GROUP BY metric_time__year - ) subq_32 + ) subq_41 ON - subq_24.metric_time__year = subq_32.metric_time__year + subq_33.metric_time__year = subq_41.metric_time__year GROUP BY metric_time__year -) subq_33 +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index c6c85ac0bc..11f3e3920c 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_5.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_5.bookings) AS bookings - , MAX(subq_14.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_14.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_14.bookings) AS bookings + , MAX(subq_23.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_3.metric_time__day - , SUM(subq_3.bookings) AS bookings + subq_12.metric_time__day + , SUM(subq_12.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.bookings + subq_11.metric_time__day + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_3 + ) subq_12 GROUP BY metric_time__day - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.bookings AS bookings_2_weeks_ago + subq_22.metric_time__day + , subq_22.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.bookings) AS bookings + subq_21.metric_time__day + , SUM(subq_21.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings + subq_20.metric_time__day + , subq_20.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_19.metric_time__day + , subq_19.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.ds__day AS ds__day - , subq_7.ds__week AS ds__week - , subq_7.ds__month AS ds__month - , subq_7.ds__quarter AS ds__quarter - , subq_7.ds__year AS ds__year - , subq_7.ds__extract_year AS ds__extract_year - , subq_7.ds__extract_quarter AS ds__extract_quarter - , subq_7.ds__extract_month AS ds__extract_month - , subq_7.ds__extract_day AS ds__extract_day - , subq_7.ds__extract_dow AS ds__extract_dow - , subq_7.ds__extract_doy AS ds__extract_doy - , subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__week AS ds_partitioned__week - , subq_7.ds_partitioned__month AS ds_partitioned__month - , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_7.ds_partitioned__year AS ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_7.paid_at__day AS paid_at__day - , subq_7.paid_at__week AS paid_at__week - , subq_7.paid_at__month AS paid_at__month - , subq_7.paid_at__quarter AS paid_at__quarter - , subq_7.paid_at__year AS paid_at__year - , subq_7.paid_at__extract_year AS paid_at__extract_year - , subq_7.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_7.paid_at__extract_month AS paid_at__extract_month - , subq_7.paid_at__extract_day AS paid_at__extract_day - , subq_7.paid_at__extract_dow AS paid_at__extract_dow - , subq_7.paid_at__extract_doy AS paid_at__extract_doy - , subq_7.booking__ds__day AS booking__ds__day - , subq_7.booking__ds__week AS booking__ds__week - , subq_7.booking__ds__month AS booking__ds__month - , subq_7.booking__ds__quarter AS booking__ds__quarter - , subq_7.booking__ds__year AS booking__ds__year - , subq_7.booking__ds__extract_year AS booking__ds__extract_year - , subq_7.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_7.booking__ds__extract_month AS booking__ds__extract_month - , subq_7.booking__ds__extract_day AS booking__ds__extract_day - , subq_7.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_7.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day AS booking__paid_at__day - , subq_7.booking__paid_at__week AS booking__paid_at__week - , subq_7.booking__paid_at__month AS booking__paid_at__month - , subq_7.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_7.booking__paid_at__year AS booking__paid_at__year - , subq_7.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_7.listing AS listing - , subq_7.guest AS guest - , subq_7.host AS host - , subq_7.booking__listing AS booking__listing - , subq_7.booking__guest AS booking__guest - , subq_7.booking__host AS booking__host - , subq_7.is_instant AS is_instant - , subq_7.booking__is_instant AS booking__is_instant - , subq_7.bookings AS bookings - , subq_7.instant_bookings AS instant_bookings - , subq_7.booking_value AS booking_value - , subq_7.max_booking_value AS max_booking_value - , subq_7.min_booking_value AS min_booking_value - , subq_7.bookers AS bookers - , subq_7.average_booking_value AS average_booking_value - , subq_7.referred_bookings AS referred_bookings - , subq_7.median_booking_value AS median_booking_value - , subq_7.booking_value_p99 AS booking_value_p99 - , subq_7.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_17.metric_time__day AS metric_time__day + , subq_16.ds__day AS ds__day + , subq_16.ds__week AS ds__week + , subq_16.ds__month AS ds__month + , subq_16.ds__quarter AS ds__quarter + , subq_16.ds__year AS ds__year + , subq_16.ds__extract_year AS ds__extract_year + , subq_16.ds__extract_quarter AS ds__extract_quarter + , subq_16.ds__extract_month AS ds__extract_month + , subq_16.ds__extract_day AS ds__extract_day + , subq_16.ds__extract_dow AS ds__extract_dow + , subq_16.ds__extract_doy AS ds__extract_doy + , subq_16.ds_partitioned__day AS ds_partitioned__day + , subq_16.ds_partitioned__week AS ds_partitioned__week + , subq_16.ds_partitioned__month AS ds_partitioned__month + , subq_16.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_16.ds_partitioned__year AS ds_partitioned__year + , subq_16.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_16.paid_at__day AS paid_at__day + , subq_16.paid_at__week AS paid_at__week + , subq_16.paid_at__month AS paid_at__month + , subq_16.paid_at__quarter AS paid_at__quarter + , subq_16.paid_at__year AS paid_at__year + , subq_16.paid_at__extract_year AS paid_at__extract_year + , subq_16.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_16.paid_at__extract_month AS paid_at__extract_month + , subq_16.paid_at__extract_day AS paid_at__extract_day + , subq_16.paid_at__extract_dow AS paid_at__extract_dow + , subq_16.paid_at__extract_doy AS paid_at__extract_doy + , subq_16.booking__ds__day AS booking__ds__day + , subq_16.booking__ds__week AS booking__ds__week + , subq_16.booking__ds__month AS booking__ds__month + , subq_16.booking__ds__quarter AS booking__ds__quarter + , subq_16.booking__ds__year AS booking__ds__year + , subq_16.booking__ds__extract_year AS booking__ds__extract_year + , subq_16.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_16.booking__ds__extract_month AS booking__ds__extract_month + , subq_16.booking__ds__extract_day AS booking__ds__extract_day + , subq_16.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_16.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day AS booking__paid_at__day + , subq_16.booking__paid_at__week AS booking__paid_at__week + , subq_16.booking__paid_at__month AS booking__paid_at__month + , subq_16.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_16.booking__paid_at__year AS booking__paid_at__year + , subq_16.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_16.listing AS listing + , subq_16.guest AS guest + , subq_16.host AS host + , subq_16.booking__listing AS booking__listing + , subq_16.booking__guest AS booking__guest + , subq_16.booking__host AS booking__host + , subq_16.is_instant AS is_instant + , subq_16.booking__is_instant AS booking__is_instant + , subq_16.bookings AS bookings + , subq_16.instant_bookings AS instant_bookings + , subq_16.booking_value AS booking_value + , subq_16.max_booking_value AS max_booking_value + , subq_16.min_booking_value AS min_booking_value + , subq_16.bookers AS bookers + , subq_16.average_booking_value AS average_booking_value + , subq_16.referred_bookings AS referred_bookings + , subq_16.median_booking_value AS median_booking_value + , subq_16.booking_value_p99 AS booking_value_p99 + , subq_16.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_16.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - ) subq_8 + subq_18.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + ) subq_17 INNER JOIN ( -- 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_15.ds__day + , subq_15.ds__week + , subq_15.ds__month + , subq_15.ds__quarter + , subq_15.ds__year + , subq_15.ds__extract_year + , subq_15.ds__extract_quarter + , subq_15.ds__extract_month + , subq_15.ds__extract_day + , subq_15.ds__extract_dow + , subq_15.ds__extract_doy + , subq_15.ds_partitioned__day + , subq_15.ds_partitioned__week + , subq_15.ds_partitioned__month + , subq_15.ds_partitioned__quarter + , subq_15.ds_partitioned__year + , subq_15.ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy + , subq_15.paid_at__day + , subq_15.paid_at__week + , subq_15.paid_at__month + , subq_15.paid_at__quarter + , subq_15.paid_at__year + , subq_15.paid_at__extract_year + , subq_15.paid_at__extract_quarter + , subq_15.paid_at__extract_month + , subq_15.paid_at__extract_day + , subq_15.paid_at__extract_dow + , subq_15.paid_at__extract_doy + , subq_15.booking__ds__day + , subq_15.booking__ds__week + , subq_15.booking__ds__month + , subq_15.booking__ds__quarter + , subq_15.booking__ds__year + , subq_15.booking__ds__extract_year + , subq_15.booking__ds__extract_quarter + , subq_15.booking__ds__extract_month + , subq_15.booking__ds__extract_day + , subq_15.booking__ds__extract_dow + , subq_15.booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day + , subq_15.booking__paid_at__week + , subq_15.booking__paid_at__month + , subq_15.booking__paid_at__quarter + , subq_15.booking__paid_at__year + , subq_15.booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy + , subq_15.ds__day AS metric_time__day + , subq_15.ds__week AS metric_time__week + , subq_15.ds__month AS metric_time__month + , subq_15.ds__quarter AS metric_time__quarter + , subq_15.ds__year AS metric_time__year + , subq_15.ds__extract_year AS metric_time__extract_year + , subq_15.ds__extract_quarter AS metric_time__extract_quarter + , subq_15.ds__extract_month AS metric_time__extract_month + , subq_15.ds__extract_day AS metric_time__extract_day + , subq_15.ds__extract_dow AS metric_time__extract_dow + , subq_15.ds__extract_doy AS metric_time__extract_doy + , subq_15.listing + , subq_15.guest + , subq_15.host + , subq_15.booking__listing + , subq_15.booking__guest + , subq_15.booking__host + , subq_15.is_instant + , subq_15.booking__is_instant + , subq_15.bookings + , subq_15.instant_bookings + , subq_15.booking_value + , subq_15.max_booking_value + , subq_15.min_booking_value + , subq_15.bookers + , subq_15.average_booking_value + , subq_15.referred_bookings + , subq_15.median_booking_value + , subq_15.booking_value_p99 + , subq_15.discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 + , subq_15.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 - ) subq_7 + , 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_15 + ) subq_16 ON - DATE_SUB(CAST(subq_8.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_7.metric_time__day - ) subq_10 - ) subq_11 + DATE_SUB(CAST(subq_17.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_16.metric_time__day + ) subq_19 + ) subq_20 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_12 + ) subq_21 GROUP BY metric_time__day - ) subq_13 - ) subq_14 + ) subq_22 + ) subq_23 ON - subq_5.metric_time__day = subq_14.metric_time__day + subq_14.metric_time__day = subq_23.metric_time__day GROUP BY metric_time__day -) subq_15 +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 7c07e7377c..8a2613d507 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_21.bookings) AS bookings - , MAX(subq_30.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_30.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_30.bookings) AS bookings + , MAX(subq_39.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -22,12 +22,12 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_21 + ) subq_30 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -39,26 +39,26 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_25.ds AS metric_time__day - , subq_23.bookings AS bookings - FROM ***************************.mf_time_spine subq_25 + subq_34.ds AS metric_time__day + , subq_32.bookings AS bookings + FROM ***************************.mf_time_spine subq_34 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 ON - DATE_SUB(CAST(subq_25.ds AS DATETIME), INTERVAL 14 day) = subq_23.metric_time__day - ) subq_27 + DATE_SUB(CAST(subq_34.ds AS DATETIME), INTERVAL 14 day) = subq_32.metric_time__day + ) subq_36 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_30 + ) subq_39 ON - subq_21.metric_time__day = subq_30.metric_time__day + subq_30.metric_time__day = subq_39.metric_time__day GROUP BY metric_time__day -) subq_31 +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql index fa913a0870..9a924ca747 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql @@ -1,433 +1,433 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookers AS every_2_days_bookers_2_days_ago + subq_18.metric_time__day + , subq_18.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , COUNT(DISTINCT subq_8.bookers) AS bookers + subq_17.metric_time__day + , COUNT(DISTINCT subq_17.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 2 day) + subq_10.metric_time__day > DATE_SUB(CAST(subq_11.metric_time__day AS DATETIME), INTERVAL 2 day) ) - ) subq_4 + ) subq_13 ON - DATE_SUB(CAST(subq_5.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_4.metric_time__day - ) subq_7 - ) subq_8 + DATE_SUB(CAST(subq_14.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_13.metric_time__day + ) subq_16 + ) subq_17 GROUP BY metric_time__day - ) subq_9 -) subq_10 + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0_optimized.sql index e1b2edc391..219f573372 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -8,26 +8,26 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , COUNT(DISTINCT subq_15.bookers) AS every_2_days_bookers_2_days_ago - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , COUNT(DISTINCT subq_24.bookers) AS every_2_days_bookers_2_days_ago + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_14.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_14 + subq_23.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_23 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC(bookings_source_src_28001.ds, day) <= subq_14.ds + DATE_TRUNC(bookings_source_src_28000.ds, day) <= subq_23.ds ) AND ( - DATE_TRUNC(bookings_source_src_28001.ds, day) > DATE_SUB(CAST(subq_14.ds AS DATETIME), INTERVAL 2 day) + DATE_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_23.ds AS DATETIME), INTERVAL 2 day) ) - ) subq_15 + ) subq_24 ON - DATE_SUB(CAST(subq_17.ds AS DATETIME), INTERVAL 2 day) = subq_15.metric_time__day + DATE_SUB(CAST(subq_26.ds AS DATETIME), INTERVAL 2 day) = subq_24.metric_time__day GROUP BY metric_time__day -) subq_21 +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0.sql index 6a7e286712..0d997facd0 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_7.booking_value) AS booking_value - , MAX(subq_12.bookers) AS bookers + COALESCE(subq_16.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_16.booking_value) AS booking_value + , MAX(subq_21.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_6.booking__ds__day - , subq_6.booking_value + subq_15.booking__ds__day + , subq_15.booking_value FROM ( -- Aggregate Measures SELECT - subq_5.booking__ds__day - , SUM(subq_5.booking_value) AS booking_value + subq_14.booking__ds__day + , SUM(subq_14.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__ds__day'] SELECT - subq_4.booking__ds__day - , subq_4.booking_value + subq_13.booking__ds__day + , subq_13.booking_value FROM ( -- Join to Time Spine Dataset SELECT - subq_2.booking__ds__day AS booking__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.booking__ds__day AS booking__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_SUB(CAST(subq_2.booking__ds__day AS DATETIME), INTERVAL 1 week) = subq_1.booking__ds__day - ) subq_4 - ) subq_5 + DATE_SUB(CAST(subq_11.booking__ds__day AS DATETIME), INTERVAL 1 week) = subq_10.booking__ds__day + ) subq_13 + ) subq_14 GROUP BY booking__ds__day - ) subq_6 - ) subq_7 + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookers + subq_20.booking__ds__day + , subq_20.bookers FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , COUNT(DISTINCT subq_10.bookers) AS bookers + subq_19.booking__ds__day + , COUNT(DISTINCT subq_19.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookers + subq_18.booking__ds__day + , subq_18.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 - ) subq_10 + , 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_17 + ) subq_18 + ) subq_19 GROUP BY booking__ds__day - ) subq_11 - ) subq_12 + ) subq_20 + ) subq_21 ON - subq_7.booking__ds__day = subq_12.booking__ds__day + subq_16.booking__ds__day = subq_21.booking__ds__day GROUP BY booking__ds__day -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql index 9ac31a60a2..e3c5b27c0a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql @@ -5,25 +5,25 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_21.booking_value) AS booking_value - , MAX(subq_26.bookers) AS bookers + COALESCE(subq_30.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_30.booking_value) AS booking_value + , MAX(subq_35.bookers) AS bookers FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['booking_value', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS booking__ds__day - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS booking__ds__day + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.mf_time_spine subq_26 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON - DATE_SUB(CAST(subq_17.ds AS DATETIME), INTERVAL 1 week) = DATE_TRUNC(bookings_source_src_28001.ds, day) + DATE_SUB(CAST(subq_26.ds AS DATETIME), INTERVAL 1 week) = DATE_TRUNC(bookings_source_src_28000.ds, day) GROUP BY booking__ds__day - ) subq_21 + ) subq_30 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -33,12 +33,12 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS booking__ds__day , COUNT(DISTINCT guest_id) AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY booking__ds__day - ) subq_26 + ) subq_35 ON - subq_21.booking__ds__day = subq_26.booking__ds__day + subq_30.booking__ds__day = subq_35.booking__ds__day GROUP BY booking__ds__day -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql index 54f41d6072..4f44456c71 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -1,319 +1,319 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_SUB(CAST(subq_11.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY metric_time__day - ) subq_6 -) subq_7 + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 7d08909b4c..0cdc736d64 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -8,19 +8,19 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago + FROM ***************************.mf_time_spine subq_20 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - DATE_SUB(CAST(subq_11.ds AS DATETIME), INTERVAL 5 day) = subq_9.metric_time__day + DATE_SUB(CAST(subq_20.ds AS DATETIME), INTERVAL 5 day) = subq_18.metric_time__day GROUP BY metric_time__day -) subq_15 +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0.sql index 5b00e7ea4e..9bfa2415dd 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0.sql @@ -1,895 +1,895 @@ -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day + subq_31.metric_time__day , non_referred + (instant * 1.0 / bookings) AS instant_plus_non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) AS metric_time__day - , MAX(subq_11.non_referred) AS non_referred - , MAX(subq_16.instant) AS instant - , MAX(subq_21.bookings) AS bookings + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day + , MAX(subq_20.non_referred) AS non_referred + , MAX(subq_25.instant) AS instant + , MAX(subq_30.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__day - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY metric_time__day - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY metric_time__day - ) subq_10 - ) subq_11 + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day - , subq_15.instant_bookings AS instant + subq_24.metric_time__day + , subq_24.instant_bookings AS instant FROM ( -- Aggregate Measures SELECT - subq_14.metric_time__day - , SUM(subq_14.instant_bookings) AS instant_bookings + subq_23.metric_time__day + , SUM(subq_23.instant_bookings) AS instant_bookings FROM ( -- Pass Only Elements: ['instant_bookings', 'metric_time__day'] SELECT - subq_13.metric_time__day - , subq_13.instant_bookings + subq_22.metric_time__day + , subq_22.instant_bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 GROUP BY metric_time__day - ) subq_15 - ) subq_16 + ) subq_24 + ) subq_25 ON - subq_11.metric_time__day = subq_16.metric_time__day + subq_20.metric_time__day = subq_25.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Aggregate Measures SELECT - subq_19.metric_time__day - , SUM(subq_19.bookings) AS bookings + subq_28.metric_time__day + , SUM(subq_28.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.bookings + subq_27.metric_time__day + , subq_27.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_17.ds__day - , subq_17.ds__week - , subq_17.ds__month - , subq_17.ds__quarter - , subq_17.ds__year - , subq_17.ds__extract_year - , subq_17.ds__extract_quarter - , subq_17.ds__extract_month - , subq_17.ds__extract_day - , subq_17.ds__extract_dow - , subq_17.ds__extract_doy - , subq_17.ds_partitioned__day - , subq_17.ds_partitioned__week - , subq_17.ds_partitioned__month - , subq_17.ds_partitioned__quarter - , subq_17.ds_partitioned__year - , subq_17.ds_partitioned__extract_year - , subq_17.ds_partitioned__extract_quarter - , subq_17.ds_partitioned__extract_month - , subq_17.ds_partitioned__extract_day - , subq_17.ds_partitioned__extract_dow - , subq_17.ds_partitioned__extract_doy - , subq_17.paid_at__day - , subq_17.paid_at__week - , subq_17.paid_at__month - , subq_17.paid_at__quarter - , subq_17.paid_at__year - , subq_17.paid_at__extract_year - , subq_17.paid_at__extract_quarter - , subq_17.paid_at__extract_month - , subq_17.paid_at__extract_day - , subq_17.paid_at__extract_dow - , subq_17.paid_at__extract_doy - , subq_17.booking__ds__day - , subq_17.booking__ds__week - , subq_17.booking__ds__month - , subq_17.booking__ds__quarter - , subq_17.booking__ds__year - , subq_17.booking__ds__extract_year - , subq_17.booking__ds__extract_quarter - , subq_17.booking__ds__extract_month - , subq_17.booking__ds__extract_day - , subq_17.booking__ds__extract_dow - , subq_17.booking__ds__extract_doy - , subq_17.booking__ds_partitioned__day - , subq_17.booking__ds_partitioned__week - , subq_17.booking__ds_partitioned__month - , subq_17.booking__ds_partitioned__quarter - , subq_17.booking__ds_partitioned__year - , subq_17.booking__ds_partitioned__extract_year - , subq_17.booking__ds_partitioned__extract_quarter - , subq_17.booking__ds_partitioned__extract_month - , subq_17.booking__ds_partitioned__extract_day - , subq_17.booking__ds_partitioned__extract_dow - , subq_17.booking__ds_partitioned__extract_doy - , subq_17.booking__paid_at__day - , subq_17.booking__paid_at__week - , subq_17.booking__paid_at__month - , subq_17.booking__paid_at__quarter - , subq_17.booking__paid_at__year - , subq_17.booking__paid_at__extract_year - , subq_17.booking__paid_at__extract_quarter - , subq_17.booking__paid_at__extract_month - , subq_17.booking__paid_at__extract_day - , subq_17.booking__paid_at__extract_dow - , subq_17.booking__paid_at__extract_doy - , subq_17.ds__day AS metric_time__day - , subq_17.ds__week AS metric_time__week - , subq_17.ds__month AS metric_time__month - , subq_17.ds__quarter AS metric_time__quarter - , subq_17.ds__year AS metric_time__year - , subq_17.ds__extract_year AS metric_time__extract_year - , subq_17.ds__extract_quarter AS metric_time__extract_quarter - , subq_17.ds__extract_month AS metric_time__extract_month - , subq_17.ds__extract_day AS metric_time__extract_day - , subq_17.ds__extract_dow AS metric_time__extract_dow - , subq_17.ds__extract_doy AS metric_time__extract_doy - , subq_17.listing - , subq_17.guest - , subq_17.host - , subq_17.booking__listing - , subq_17.booking__guest - , subq_17.booking__host - , subq_17.is_instant - , subq_17.booking__is_instant - , subq_17.bookings - , subq_17.instant_bookings - , subq_17.booking_value - , subq_17.max_booking_value - , subq_17.min_booking_value - , subq_17.bookers - , subq_17.average_booking_value - , subq_17.referred_bookings - , subq_17.median_booking_value - , subq_17.booking_value_p99 - , subq_17.discrete_booking_value_p99 - , subq_17.approximate_continuous_booking_value_p99 - , subq_17.approximate_discrete_booking_value_p99 + subq_26.ds__day + , subq_26.ds__week + , subq_26.ds__month + , subq_26.ds__quarter + , subq_26.ds__year + , subq_26.ds__extract_year + , subq_26.ds__extract_quarter + , subq_26.ds__extract_month + , subq_26.ds__extract_day + , subq_26.ds__extract_dow + , subq_26.ds__extract_doy + , subq_26.ds_partitioned__day + , subq_26.ds_partitioned__week + , subq_26.ds_partitioned__month + , subq_26.ds_partitioned__quarter + , subq_26.ds_partitioned__year + , subq_26.ds_partitioned__extract_year + , subq_26.ds_partitioned__extract_quarter + , subq_26.ds_partitioned__extract_month + , subq_26.ds_partitioned__extract_day + , subq_26.ds_partitioned__extract_dow + , subq_26.ds_partitioned__extract_doy + , subq_26.paid_at__day + , subq_26.paid_at__week + , subq_26.paid_at__month + , subq_26.paid_at__quarter + , subq_26.paid_at__year + , subq_26.paid_at__extract_year + , subq_26.paid_at__extract_quarter + , subq_26.paid_at__extract_month + , subq_26.paid_at__extract_day + , subq_26.paid_at__extract_dow + , subq_26.paid_at__extract_doy + , subq_26.booking__ds__day + , subq_26.booking__ds__week + , subq_26.booking__ds__month + , subq_26.booking__ds__quarter + , subq_26.booking__ds__year + , subq_26.booking__ds__extract_year + , subq_26.booking__ds__extract_quarter + , subq_26.booking__ds__extract_month + , subq_26.booking__ds__extract_day + , subq_26.booking__ds__extract_dow + , subq_26.booking__ds__extract_doy + , subq_26.booking__ds_partitioned__day + , subq_26.booking__ds_partitioned__week + , subq_26.booking__ds_partitioned__month + , subq_26.booking__ds_partitioned__quarter + , subq_26.booking__ds_partitioned__year + , subq_26.booking__ds_partitioned__extract_year + , subq_26.booking__ds_partitioned__extract_quarter + , subq_26.booking__ds_partitioned__extract_month + , subq_26.booking__ds_partitioned__extract_day + , subq_26.booking__ds_partitioned__extract_dow + , subq_26.booking__ds_partitioned__extract_doy + , subq_26.booking__paid_at__day + , subq_26.booking__paid_at__week + , subq_26.booking__paid_at__month + , subq_26.booking__paid_at__quarter + , subq_26.booking__paid_at__year + , subq_26.booking__paid_at__extract_year + , subq_26.booking__paid_at__extract_quarter + , subq_26.booking__paid_at__extract_month + , subq_26.booking__paid_at__extract_day + , subq_26.booking__paid_at__extract_dow + , subq_26.booking__paid_at__extract_doy + , subq_26.ds__day AS metric_time__day + , subq_26.ds__week AS metric_time__week + , subq_26.ds__month AS metric_time__month + , subq_26.ds__quarter AS metric_time__quarter + , subq_26.ds__year AS metric_time__year + , subq_26.ds__extract_year AS metric_time__extract_year + , subq_26.ds__extract_quarter AS metric_time__extract_quarter + , subq_26.ds__extract_month AS metric_time__extract_month + , subq_26.ds__extract_day AS metric_time__extract_day + , subq_26.ds__extract_dow AS metric_time__extract_dow + , subq_26.ds__extract_doy AS metric_time__extract_doy + , subq_26.listing + , subq_26.guest + , subq_26.host + , subq_26.booking__listing + , subq_26.booking__guest + , subq_26.booking__host + , subq_26.is_instant + , subq_26.booking__is_instant + , subq_26.bookings + , subq_26.instant_bookings + , subq_26.booking_value + , subq_26.max_booking_value + , subq_26.min_booking_value + , subq_26.bookers + , subq_26.average_booking_value + , subq_26.referred_bookings + , subq_26.median_booking_value + , subq_26.booking_value_p99 + , subq_26.discrete_booking_value_p99 + , subq_26.approximate_continuous_booking_value_p99 + , subq_26.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_17 - ) subq_18 - ) subq_19 + , 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_26 + ) subq_27 + ) subq_28 GROUP BY metric_time__day - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 ON - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day) = subq_21.metric_time__day + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day) = subq_30.metric_time__day GROUP BY metric_time__day -) subq_22 +) subq_31 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0_optimized.sql index 01e8970931..b8c118ace3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) AS metric_time__day - , MAX(subq_34.non_referred) AS non_referred - , MAX(subq_39.instant) AS instant - , MAX(subq_44.bookings) AS bookings + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day, subq_53.metric_time__day) AS metric_time__day + , MAX(subq_43.non_referred) AS non_referred + , MAX(subq_48.instant) AS instant + , MAX(subq_53.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -17,9 +17,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.ref_bookings) AS ref_bookings - , MAX(subq_32.bookings) AS bookings + COALESCE(subq_36.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_36.ref_bookings) AS ref_bookings + , MAX(subq_41.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -33,11 +33,11 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_25 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_34 GROUP BY metric_time__day - ) subq_27 + ) subq_36 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -51,17 +51,17 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_30 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_39 GROUP BY metric_time__day - ) subq_32 + ) subq_41 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_36.metric_time__day = subq_41.metric_time__day GROUP BY metric_time__day - ) subq_33 - ) subq_34 + ) subq_42 + ) subq_43 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -75,13 +75,13 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_37 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_46 GROUP BY metric_time__day - ) subq_39 + ) subq_48 ON - subq_34.metric_time__day = subq_39.metric_time__day + subq_43.metric_time__day = subq_48.metric_time__day FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -95,13 +95,13 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_42 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_51 GROUP BY metric_time__day - ) subq_44 + ) subq_53 ON - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day) = subq_44.metric_time__day + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day) = subq_53.metric_time__day GROUP BY metric_time__day -) subq_45 +) subq_54 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 679f1017aa..2e7af726e6 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -1,359 +1,359 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Pass Only Elements: ['metric_time__day', 'bookings_offset_once'] SELECT - subq_12.metric_time__day - , subq_12.bookings_offset_once + subq_21.metric_time__day + , subq_21.bookings_offset_once FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.booking__is_instant - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.booking__is_instant + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.booking__is_instant AS booking__is_instant - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.booking__is_instant AS booking__is_instant + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant + subq_16.metric_time__day + , subq_16.booking__is_instant , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.bookings + subq_15.metric_time__day + , subq_15.booking__is_instant + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , subq_14.booking__is_instant + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_13.metric_time__day + , subq_13.booking__is_instant + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_SUB(CAST(subq_11.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY metric_time__day , booking__is_instant - ) subq_6 - ) subq_7 - ) subq_8 + ) subq_15 + ) subq_16 + ) subq_17 ON - DATE_SUB(CAST(subq_9.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_8.metric_time__day - ) subq_11 + DATE_SUB(CAST(subq_18.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_17.metric_time__day + ) subq_20 WHERE booking__is_instant - ) subq_12 -) subq_13 + ) subq_21 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index c8d2c6d5e3..ce5f38f92c 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -11,10 +11,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_24.ds AS metric_time__day - , subq_22.booking__is_instant AS booking__is_instant - , subq_22.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_24 + subq_33.ds AS metric_time__day + , subq_31.booking__is_instant AS booking__is_instant + , subq_31.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_33 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -27,10 +27,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , subq_15.booking__is_instant AS booking__is_instant - , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , subq_24.booking__is_instant AS booking__is_instant + , SUM(subq_24.bookings) AS bookings + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -38,17 +38,17 @@ FROM ( DATE_TRUNC(ds, day) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 ON - DATE_SUB(CAST(subq_17.ds AS DATETIME), INTERVAL 5 day) = subq_15.metric_time__day + DATE_SUB(CAST(subq_26.ds AS DATETIME), INTERVAL 5 day) = subq_24.metric_time__day GROUP BY metric_time__day , booking__is_instant - ) subq_21 - ) subq_22 + ) subq_30 + ) subq_31 ON - DATE_SUB(CAST(subq_24.ds AS DATETIME), INTERVAL 2 day) = subq_22.metric_time__day - ) subq_25 + DATE_SUB(CAST(subq_33.ds AS DATETIME), INTERVAL 2 day) = subq_31.metric_time__day + ) subq_34 WHERE booking__is_instant -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql index d57a33a14b..338065a058 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql @@ -1,471 +1,471 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , booking_fees - booking_fees_start_of_month AS booking_fees_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_8.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_8.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_14.booking_fees) AS booking_fees + COALESCE(subq_17.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_17.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_23.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.booking_fees_start_of_month AS booking_fees_start_of_month + subq_15.metric_time__day AS metric_time__day + , subq_14.booking_fees_start_of_month AS booking_fees_start_of_month FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_6 + subq_16.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + ) subq_15 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day + subq_13.metric_time__day , booking_value * 0.05 AS booking_fees_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.booking_value) AS booking_value + subq_11.metric_time__day + , SUM(subq_11.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__day - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_12 + ) subq_13 + ) subq_14 ON - DATE_TRUNC(subq_6.metric_time__day, month) = subq_5.metric_time__day - ) subq_8 + DATE_TRUNC(subq_15.metric_time__day, month) = subq_14.metric_time__day + ) subq_17 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , booking_value * 0.05 AS booking_fees FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value + subq_21.metric_time__day + , subq_21.booking_value FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_20.metric_time__day + , SUM(subq_20.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_19.metric_time__day + , subq_19.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__extract_quarter - , subq_9.ds__extract_month - , subq_9.ds__extract_day - , subq_9.ds__extract_dow - , subq_9.ds__extract_doy - , subq_9.ds_partitioned__day - , subq_9.ds_partitioned__week - , subq_9.ds_partitioned__month - , subq_9.ds_partitioned__quarter - , subq_9.ds_partitioned__year - , subq_9.ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy - , subq_9.paid_at__day - , subq_9.paid_at__week - , subq_9.paid_at__month - , subq_9.paid_at__quarter - , subq_9.paid_at__year - , subq_9.paid_at__extract_year - , subq_9.paid_at__extract_quarter - , subq_9.paid_at__extract_month - , subq_9.paid_at__extract_day - , subq_9.paid_at__extract_dow - , subq_9.paid_at__extract_doy - , subq_9.booking__ds__day - , subq_9.booking__ds__week - , subq_9.booking__ds__month - , subq_9.booking__ds__quarter - , subq_9.booking__ds__year - , subq_9.booking__ds__extract_year - , subq_9.booking__ds__extract_quarter - , subq_9.booking__ds__extract_month - , subq_9.booking__ds__extract_day - , subq_9.booking__ds__extract_dow - , subq_9.booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day - , subq_9.booking__paid_at__week - , subq_9.booking__paid_at__month - , subq_9.booking__paid_at__quarter - , subq_9.booking__paid_at__year - , subq_9.booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy - , subq_9.ds__day AS metric_time__day - , subq_9.ds__week AS metric_time__week - , subq_9.ds__month AS metric_time__month - , subq_9.ds__quarter AS metric_time__quarter - , subq_9.ds__year AS metric_time__year - , subq_9.ds__extract_year AS metric_time__extract_year - , subq_9.ds__extract_quarter AS metric_time__extract_quarter - , subq_9.ds__extract_month AS metric_time__extract_month - , subq_9.ds__extract_day AS metric_time__extract_day - , subq_9.ds__extract_dow AS metric_time__extract_dow - , subq_9.ds__extract_doy AS metric_time__extract_doy - , subq_9.listing - , subq_9.guest - , subq_9.host - , subq_9.booking__listing - , subq_9.booking__guest - , subq_9.booking__host - , subq_9.is_instant - , subq_9.booking__is_instant - , subq_9.bookings - , subq_9.instant_bookings - , subq_9.booking_value - , subq_9.max_booking_value - , subq_9.min_booking_value - , subq_9.bookers - , subq_9.average_booking_value - , subq_9.referred_bookings - , subq_9.median_booking_value - , subq_9.booking_value_p99 - , subq_9.discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 + 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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 - ) subq_10 - ) subq_11 + , 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_18 + ) subq_19 + ) subq_20 GROUP BY metric_time__day - ) subq_12 - ) subq_13 - ) subq_14 + ) subq_21 + ) subq_22 + ) subq_23 ON - subq_8.metric_time__day = subq_14.metric_time__day + subq_17.metric_time__day = subq_23.metric_time__day GROUP BY metric_time__day -) subq_15 +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql index ffc76505df..8b3b69ee18 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_24.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_30.booking_fees) AS booking_fees + COALESCE(subq_33.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_33.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_39.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.booking_fees_start_of_month AS booking_fees_start_of_month - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.booking_fees_start_of_month AS booking_fees_start_of_month + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,14 +28,14 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY metric_time__day - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 ON - DATE_TRUNC(subq_23.ds, month) = subq_21.metric_time__day - ) subq_24 + DATE_TRUNC(subq_32.ds, month) = subq_30.metric_time__day + ) subq_33 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT @@ -50,13 +50,13 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY metric_time__day - ) subq_29 - ) subq_30 + ) subq_38 + ) subq_39 ON - subq_24.metric_time__day = subq_30.metric_time__day + subq_33.metric_time__day = subq_39.metric_time__day GROUP BY metric_time__day -) subq_31 +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0.sql index c3ec7a2819..8da244d87d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0.sql @@ -8,991 +8,991 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_30.booking_value) AS booking_value + MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.average_booking_value + subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_9.average_booking_value) AS average_booking_value + AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_8.average_booking_value + subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.booking__is_instant + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.booking__is_instant + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value 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_2.average_booking_value AS average_booking_value + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.average_booking_value + subq_10.listing + , subq_10.booking__is_instant + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_8 - ) subq_9 - ) subq_10 - ) subq_11 + ) subq_17 + ) subq_18 + ) subq_19 + ) subq_20 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.bookings + subq_31.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_21.bookings) AS bookings + SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_20.bookings + subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.booking__is_instant - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.booking__is_instant + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_18.booking__is_instant - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.listing AS listing - , subq_14.booking__is_instant AS booking__is_instant - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.listing AS listing + , subq_23.booking__is_instant AS booking__is_instant + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_13.listing - , subq_13.booking__is_instant - , subq_13.bookings + subq_22.listing + , subq_22.booking__is_instant + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_20 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_29 + ) subq_30 + ) subq_31 + ) subq_32 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_29.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_28.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_27.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 -) subq_32 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0_optimized.sql index 14649c62dd..35859d3713 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0_optimized.sql +++ b/metricflow/test/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_44.average_booking_value) AS average_booking_value - , MAX(subq_56.bookings) AS bookings - , MAX(subq_63.booking_value) AS booking_value + MAX(subq_53.average_booking_value) AS average_booking_value + , MAX(subq_65.bookings) AS bookings + , MAX(subq_72.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,17 +22,17 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - bookings_source_src_28001.is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_40 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_49 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_44 + ) subq_53 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -44,9 +44,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_47.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_47.bookings AS bookings + subq_56.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_56.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -55,15 +55,15 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_47 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_56 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_47.listing = listings_latest_src_28005.listing_id - ) subq_52 + subq_56.listing = listings_latest_src_28000.listing_id + ) subq_61 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_56 + ) subq_65 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -78,9 +78,9 @@ FROM ( SELECT is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_59 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_68 WHERE booking__is_instant - ) subq_63 - ) subq_64 -) subq_65 + ) subq_72 + ) subq_73 +) subq_74 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0.sql index 0e363a5bea..45ae5e73c3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0.sql @@ -1,339 +1,339 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_SUB(CAST(subq_11.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + ) subq_15 + ) subq_16 + ) subq_17 ON - DATE_SUB(CAST(subq_9.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_8.metric_time__day -) subq_11 + DATE_SUB(CAST(subq_18.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0_optimized.sql index 6ccdca5949..aec04b98d6 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -19,23 +19,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - DATE_SUB(CAST(subq_15.ds AS DATETIME), INTERVAL 5 day) = subq_13.metric_time__day + DATE_SUB(CAST(subq_24.ds AS DATETIME), INTERVAL 5 day) = subq_22.metric_time__day GROUP BY metric_time__day - ) subq_19 - ) subq_20 + ) subq_28 + ) subq_29 ON - DATE_SUB(CAST(subq_22.ds AS DATETIME), INTERVAL 2 day) = subq_20.metric_time__day -) subq_23 + DATE_SUB(CAST(subq_31.ds AS DATETIME), INTERVAL 2 day) = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0.sql index 6d2d03942f..4a49e9f729 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0.sql @@ -1,340 +1,340 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - WHERE subq_10.ds BETWEEN '2020-01-12' AND '2020-01-13' - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + WHERE subq_19.ds BETWEEN '2020-01-12' AND '2020-01-13' + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_SUB(CAST(subq_11.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + ) subq_15 + ) subq_16 + ) subq_17 ON - DATE_SUB(CAST(subq_9.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_8.metric_time__day -) subq_11 + DATE_SUB(CAST(subq_18.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 6a5e37b13e..a1c5d1a4a5 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_21.metric_time__day AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once + subq_30.metric_time__day AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_22 + FROM ***************************.mf_time_spine subq_31 WHERE ds BETWEEN '2020-01-12' AND '2020-01-13' - ) subq_21 + ) subq_30 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -25,23 +25,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - DATE_SUB(CAST(subq_15.ds AS DATETIME), INTERVAL 5 day) = subq_13.metric_time__day + DATE_SUB(CAST(subq_24.ds AS DATETIME), INTERVAL 5 day) = subq_22.metric_time__day GROUP BY metric_time__day - ) subq_19 - ) subq_20 + ) subq_28 + ) subq_29 ON - DATE_SUB(CAST(subq_21.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_20.metric_time__day -) subq_23 + DATE_SUB(CAST(subq_30.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0.sql index 4775f4046c..b86725807c 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0.sql @@ -1,346 +1,346 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day + subq_21.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_SUB(CAST(subq_11.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + ) subq_15 + ) subq_16 + ) subq_17 ON - DATE_SUB(CAST(subq_9.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_8.metric_time__day - ) subq_11 + DATE_SUB(CAST(subq_18.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_17.metric_time__day + ) subq_20 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_12 +) subq_21 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0_optimized.sql index a19f6253a1..0537f77e49 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -10,9 +10,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,25 +24,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.ds AS metric_time__day - , SUM(subq_14.bookings) AS bookings - FROM ***************************.mf_time_spine subq_16 + subq_25.ds AS metric_time__day + , SUM(subq_23.bookings) AS bookings + FROM ***************************.mf_time_spine subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_14 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_23 ON - DATE_SUB(CAST(subq_16.ds AS DATETIME), INTERVAL 5 day) = subq_14.metric_time__day + DATE_SUB(CAST(subq_25.ds AS DATETIME), INTERVAL 5 day) = subq_23.metric_time__day GROUP BY metric_time__day - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 ON - DATE_SUB(CAST(subq_23.ds AS DATETIME), INTERVAL 2 day) = subq_21.metric_time__day - ) subq_24 + DATE_SUB(CAST(subq_32.ds AS DATETIME), INTERVAL 2 day) = subq_30.metric_time__day + ) subq_33 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_25 +) subq_34 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0.sql index 45846b3999..683f460fe5 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY booking__ds__day - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.booking__ds__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC(subq_7.booking__ds__day, month) = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + DATE_TRUNC(subq_16.booking__ds__day, month) = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY booking__ds__day - ) subq_11 - ) subq_12 + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY booking__ds__day -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql index 6a4f47cc54..80492a487e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC(subq_22.ds, month) = subq_20.booking__ds__day + DATE_TRUNC(subq_31.ds, month) = subq_29.booking__ds__day GROUP BY booking__ds__day - ) subq_26 + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY booking__ds__day -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0.sql index c855ed38d8..0c43e3eb97 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY booking__ds__day - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.booking__ds__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_SUB(CAST(subq_7.booking__ds__day AS DATETIME), INTERVAL 14 day) = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + DATE_SUB(CAST(subq_16.booking__ds__day AS DATETIME), INTERVAL 14 day) = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY booking__ds__day - ) subq_11 - ) subq_12 + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY booking__ds__day -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0_optimized.sql index 7fd58814bc..852a256564 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_SUB(CAST(subq_22.ds AS DATETIME), INTERVAL 14 day) = subq_20.booking__ds__day + DATE_SUB(CAST(subq_31.ds AS DATETIME), INTERVAL 14 day) = subq_29.booking__ds__day GROUP BY booking__ds__day - ) subq_26 + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY booking__ds__day -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0.sql index 4e204fef06..2398c4f3b5 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0.sql @@ -1,320 +1,320 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - WHERE subq_3.ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + WHERE subq_12.ds BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_SUB(CAST(subq_11.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY metric_time__day - ) subq_6 -) subq_7 + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0_optimized.sql index 4e0b8eddb8..8a38a0a36f 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -8,25 +8,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago + subq_19.metric_time__day AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_20 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_10 + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - DATE_SUB(CAST(subq_10.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_9.metric_time__day + DATE_SUB(CAST(subq_19.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_18.metric_time__day GROUP BY metric_time__day -) subq_15 +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index d975878710..6c8fa6b9ae 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -1,441 +1,441 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.bookers AS every_2_days_bookers_2_days_ago + subq_19.metric_time__day + , subq_19.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , COUNT(DISTINCT subq_9.bookers) AS bookers + subq_18.metric_time__day + , COUNT(DISTINCT subq_18.bookers) AS bookers FROM ( -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] SELECT - subq_8.metric_time__day - , subq_8.bookers + subq_17.metric_time__day + , subq_17.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -2, subq_11.metric_time__day) ) - ) subq_4 + ) subq_13 ON - DATEADD(day, -2, subq_5.metric_time__day) = subq_4.metric_time__day - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_9 + DATEADD(day, -2, subq_14.metric_time__day) = subq_13.metric_time__day + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 -) subq_11 + subq_18.metric_time__day + ) subq_19 +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index d998382fb8..0f2d801995 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -9,33 +9,33 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day AS metric_time__day - , COUNT(DISTINCT subq_16.bookers) AS every_2_days_bookers_2_days_ago + subq_26.metric_time__day AS metric_time__day + , COUNT(DISTINCT subq_25.bookers) AS every_2_days_bookers_2_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_18 + FROM ***************************.mf_time_spine subq_27 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_17 + ) subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_15.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_24 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_15.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_24.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATEADD(day, -2, subq_15.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_24.ds) ) - ) subq_16 + ) subq_25 ON - DATEADD(day, -2, subq_17.metric_time__day) = subq_16.metric_time__day - WHERE subq_17.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' + DATEADD(day, -2, subq_26.metric_time__day) = subq_25.metric_time__day + WHERE subq_26.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' GROUP BY - subq_17.metric_time__day -) subq_23 + subq_26.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0.sql index 08cb56bfde..04cc877c0b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0.sql @@ -1,445 +1,445 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_16.metric_time__day + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) -) subq_10 + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0_optimized.sql index 23f7234c6e..1638560b4d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , MAX(subq_15.ref_bookings) AS ref_bookings - , MAX(subq_20.bookings) AS bookings + COALESCE(subq_24.metric_time__day, subq_29.metric_time__day) AS metric_time__day + , MAX(subq_24.ref_bookings) AS ref_bookings + , MAX(subq_29.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,11 +21,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 GROUP BY metric_time__day - ) subq_15 + ) subq_24 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,13 +39,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_15.metric_time__day = subq_20.metric_time__day + subq_24.metric_time__day = subq_29.metric_time__day GROUP BY - COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) -) subq_21 + COALESCE(subq_24.metric_time__day, subq_29.metric_time__day) +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 72735021e2..35be63856a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -1,73 +1,73 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__month + subq_9.metric_time__month , bookings_last_month AS bookings_last_month FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly AS bookings_last_month + subq_8.metric_time__month + , subq_8.bookings_monthly AS bookings_last_month FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__month - , SUM(subq_5.bookings_monthly) AS bookings_monthly + subq_7.metric_time__month + , SUM(subq_7.bookings_monthly) AS bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_4.metric_time__month - , subq_4.bookings_monthly + subq_6.metric_time__month + , subq_6.bookings_monthly FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__month AS metric_time__month - , subq_1.monthly_ds__month AS monthly_ds__month - , subq_1.monthly_ds__quarter AS monthly_ds__quarter - , subq_1.monthly_ds__year AS monthly_ds__year - , subq_1.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_1.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_1.listing AS listing - , subq_1.booking__listing AS booking__listing - , subq_1.bookings_monthly AS bookings_monthly + subq_4.metric_time__month AS metric_time__month + , subq_3.monthly_ds__month AS monthly_ds__month + , subq_3.monthly_ds__quarter AS monthly_ds__quarter + , subq_3.monthly_ds__year AS monthly_ds__year + , subq_3.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_3.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_3.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_3.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_3.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_3.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_3.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_3.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_3.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_3.listing AS listing + , subq_3.booking__listing AS booking__listing + , subq_3.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_3.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_3 + DATE_TRUNC('month', subq_5.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_5 GROUP BY - DATE_TRUNC('month', subq_3.ds) - ) subq_2 + DATE_TRUNC('month', subq_5.ds) + ) subq_4 INNER JOIN ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_2.monthly_ds__month + , subq_2.monthly_ds__quarter + , subq_2.monthly_ds__year + , subq_2.monthly_ds__extract_year + , subq_2.monthly_ds__extract_quarter + , subq_2.monthly_ds__extract_month + , subq_2.booking__monthly_ds__month + , subq_2.booking__monthly_ds__quarter + , subq_2.booking__monthly_ds__year + , subq_2.booking__monthly_ds__extract_year + , subq_2.booking__monthly_ds__extract_quarter + , subq_2.booking__monthly_ds__extract_month + , subq_2.monthly_ds__month AS metric_time__month + , subq_2.monthly_ds__quarter AS metric_time__quarter + , subq_2.monthly_ds__year AS metric_time__year + , subq_2.monthly_ds__extract_year AS metric_time__extract_year + , subq_2.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_2.monthly_ds__extract_month AS metric_time__extract_month + , subq_2.listing + , subq_2.booking__listing + , subq_2.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -87,13 +87,13 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 + ) subq_2 + ) subq_3 ON - DATEADD(month, -1, subq_2.metric_time__month) = subq_1.metric_time__month - ) subq_4 - ) subq_5 + DATEADD(month, -1, subq_4.metric_time__month) = subq_3.metric_time__month + ) subq_6 + ) subq_7 GROUP BY - subq_5.metric_time__month - ) subq_6 -) subq_7 + subq_7.metric_time__month + ) subq_8 +) subq_9 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index ccd562cfa6..75916f38d4 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -8,20 +8,20 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month AS metric_time__month + subq_12.metric_time__month AS metric_time__month , SUM(bookings_monthly_source_src_16000.bookings_monthly) AS bookings_last_month FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_13 GROUP BY DATE_TRUNC('month', ds) - ) subq_10 + ) subq_12 INNER JOIN ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 ON - DATEADD(month, -1, subq_10.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_16000.ds) + DATEADD(month, -1, subq_12.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_16000.ds) GROUP BY - subq_10.metric_time__month -) subq_15 + subq_12.metric_time__month +) subq_17 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql index b833c0ffae..b40c3941e3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__day - ) subq_11 - ) subq_12 + subq_19.metric_time__day + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) -) subq_13 + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 5138fe8ae6..2061be23cf 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day + DATE_TRUNC('month', subq_31.ds) = subq_29.metric_time__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) -) subq_27 + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index cfe4bb809a..6355c29553 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -1,546 +1,546 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__week + subq_22.metric_time__week , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) AS metric_time__week - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__week, subq_21.metric_time__week) AS metric_time__week + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__week - , subq_3.bookings + subq_12.metric_time__week + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__week - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__week + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_1.metric_time__week - , subq_1.bookings + subq_10.metric_time__week + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__week - ) subq_3 - ) subq_4 + subq_11.metric_time__week + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__week - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__week + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__week - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__week + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_9.metric_time__week - , subq_9.bookings + subq_18.metric_time__week + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('week', subq_7.metric_time__day) AS metric_time__week - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('week', subq_16.metric_time__day) AS metric_time__week + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.metric_time__day) = subq_6.metric_time__day - WHERE DATE_TRUNC('week', subq_7.metric_time__day) = subq_7.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.metric_time__day) = subq_15.metric_time__day + WHERE DATE_TRUNC('week', subq_16.metric_time__day) = subq_16.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__week - ) subq_11 - ) subq_12 + subq_19.metric_time__week + ) subq_20 + ) subq_21 ON - subq_4.metric_time__week = subq_12.metric_time__week + subq_13.metric_time__week = subq_21.metric_time__week GROUP BY - COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) -) subq_13 + COALESCE(subq_13.metric_time__week, subq_21.metric_time__week) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index b9e4162413..65cf132abd 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) AS metric_time__week - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__week, subq_35.metric_time__week) AS metric_time__week + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,36 +21,36 @@ FROM ( SELECT DATE_TRUNC('week', ds) AS metric_time__week , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__week - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__week'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('week', subq_22.ds) AS metric_time__week - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC('week', subq_31.ds) AS metric_time__week + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day - WHERE DATE_TRUNC('week', subq_22.ds) = subq_22.ds + DATE_TRUNC('month', subq_31.ds) = subq_29.metric_time__day + WHERE DATE_TRUNC('week', subq_31.ds) = subq_31.ds GROUP BY - DATE_TRUNC('week', subq_22.ds) - ) subq_26 + DATE_TRUNC('week', subq_31.ds) + ) subq_35 ON - subq_18.metric_time__week = subq_26.metric_time__week + subq_27.metric_time__week = subq_35.metric_time__week GROUP BY - COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) -) subq_27 + COALESCE(subq_27.metric_time__week, subq_35.metric_time__week) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql index 83c1b130c2..64918564ce 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATEADD(day, -14, subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATEADD(day, -14, subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__day - ) subq_11 - ) subq_12 + subq_19.metric_time__day + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) -) subq_13 + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql index 197f4d5430..ba542c8a14 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_31.ds) = subq_29.metric_time__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) -) subq_27 + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 3ebcc29772..ce6630401e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__quarter + subq_22.metric_time__quarter , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) AS metric_time__quarter - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__quarter, subq_21.metric_time__quarter) AS metric_time__quarter + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__quarter - , subq_3.bookings + subq_12.metric_time__quarter + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__quarter - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__quarter + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_1.metric_time__quarter - , subq_1.bookings + subq_10.metric_time__quarter + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__quarter - ) subq_3 - ) subq_4 + subq_11.metric_time__quarter + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__quarter - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__quarter + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__quarter - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__quarter + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_9.metric_time__quarter - , subq_9.bookings + subq_18.metric_time__quarter + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('quarter', subq_7.metric_time__day) AS metric_time__quarter - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('quarter', subq_16.metric_time__day) AS metric_time__quarter + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATEADD(day, -14, subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATEADD(day, -14, subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__quarter - ) subq_11 - ) subq_12 + subq_19.metric_time__quarter + ) subq_20 + ) subq_21 ON - subq_4.metric_time__quarter = subq_12.metric_time__quarter + subq_13.metric_time__quarter = subq_21.metric_time__quarter GROUP BY - COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) -) subq_13 + COALESCE(subq_13.metric_time__quarter, subq_21.metric_time__quarter) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index 89f6dcf4d2..d31ffad9a6 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) AS metric_time__quarter - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__quarter, subq_35.metric_time__quarter) AS metric_time__quarter + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('quarter', ds) AS metric_time__quarter , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__quarter - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__quarter'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('quarter', subq_22.ds) AS metric_time__quarter - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC('quarter', subq_31.ds) AS metric_time__quarter + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_31.ds) = subq_29.metric_time__day GROUP BY - DATE_TRUNC('quarter', subq_22.ds) - ) subq_26 + DATE_TRUNC('quarter', subq_31.ds) + ) subq_35 ON - subq_18.metric_time__quarter = subq_26.metric_time__quarter + subq_27.metric_time__quarter = subq_35.metric_time__quarter GROUP BY - COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) -) subq_27 + COALESCE(subq_27.metric_time__quarter, subq_35.metric_time__quarter) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 4f5c379351..956debe353 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -1,645 +1,645 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__day + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC('month', subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 + subq_14.metric_time__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATEADD(month, -1, subq_10.metric_time__day) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATEADD(month, -1, subq_19.metric_time__day) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__day - ) subq_14 - ) subq_15 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) -) subq_16 + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 1f8ce4023a..bedc1e94c6 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -5,55 +5,55 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_20.ds AS metric_time__day - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + subq_29.ds AS metric_time__day + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day + DATE_TRUNC('month', subq_29.ds) = subq_27.metric_time__day GROUP BY - subq_20.ds - ) subq_24 + subq_29.ds + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATEADD(month, -1, subq_28.ds) = subq_26.metric_time__day + DATEADD(month, -1, subq_37.ds) = subq_35.metric_time__day GROUP BY - subq_28.ds - ) subq_32 + subq_37.ds + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index aab4084404..c94bf5db54 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -1,646 +1,646 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__year + subq_25.metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) AS metric_time__year - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__year, subq_24.metric_time__year) AS metric_time__year + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__year - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__year + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__year - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__year + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_4.metric_time__year - , subq_4.bookings + subq_13.metric_time__year + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('year', subq_11.metric_time__day) AS metric_time__year + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - WHERE DATE_TRUNC('year', subq_2.metric_time__day) = subq_2.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC('month', subq_11.metric_time__day) = subq_10.metric_time__day + WHERE DATE_TRUNC('year', subq_11.metric_time__day) = subq_11.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__year - ) subq_6 - ) subq_7 + subq_14.metric_time__year + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__year - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__year + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__year - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__year + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_12.metric_time__year - , subq_12.bookings + subq_21.metric_time__year + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_10.metric_time__day) AS metric_time__year - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('year', subq_19.metric_time__day) AS metric_time__year + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATEADD(month, -1, subq_10.metric_time__day) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATEADD(month, -1, subq_19.metric_time__day) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__year - ) subq_14 - ) subq_15 + subq_22.metric_time__year + ) subq_23 + ) subq_24 ON - subq_7.metric_time__year = subq_15.metric_time__year + subq_16.metric_time__year = subq_24.metric_time__year GROUP BY - COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) -) subq_16 + COALESCE(subq_16.metric_time__year, subq_24.metric_time__year) +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 6df1bd72d2..3b62cf5d4b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,56 +5,56 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) AS metric_time__year - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__year, subq_41.metric_time__year) AS metric_time__year + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_20.ds) AS metric_time__year - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + DATE_TRUNC('year', subq_29.ds) AS metric_time__year + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day - WHERE DATE_TRUNC('year', subq_20.ds) = subq_20.ds + DATE_TRUNC('month', subq_29.ds) = subq_27.metric_time__day + WHERE DATE_TRUNC('year', subq_29.ds) = subq_29.ds GROUP BY - DATE_TRUNC('year', subq_20.ds) - ) subq_24 + DATE_TRUNC('year', subq_29.ds) + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_28.ds) AS metric_time__year - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + DATE_TRUNC('year', subq_37.ds) AS metric_time__year + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATEADD(month, -1, subq_28.ds) = subq_26.metric_time__day + DATEADD(month, -1, subq_37.ds) = subq_35.metric_time__day GROUP BY - DATE_TRUNC('year', subq_28.ds) - ) subq_32 + DATE_TRUNC('year', subq_37.ds) + ) subq_41 ON - subq_24.metric_time__year = subq_32.metric_time__year + subq_33.metric_time__year = subq_41.metric_time__year GROUP BY - COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) -) subq_33 + COALESCE(subq_33.metric_time__year, subq_41.metric_time__year) +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 45894aea50..cd9c9ad6b4 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_5.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_5.bookings) AS bookings - , MAX(subq_14.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_14.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_14.bookings) AS bookings + , MAX(subq_23.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_3.metric_time__day - , SUM(subq_3.bookings) AS bookings + subq_12.metric_time__day + , SUM(subq_12.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.bookings + subq_11.metric_time__day + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_3 + ) subq_12 GROUP BY - subq_3.metric_time__day - ) subq_4 - ) subq_5 + subq_12.metric_time__day + ) subq_13 + ) subq_14 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.bookings AS bookings_2_weeks_ago + subq_22.metric_time__day + , subq_22.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.bookings) AS bookings + subq_21.metric_time__day + , SUM(subq_21.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings + subq_20.metric_time__day + , subq_20.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_19.metric_time__day + , subq_19.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.ds__day AS ds__day - , subq_7.ds__week AS ds__week - , subq_7.ds__month AS ds__month - , subq_7.ds__quarter AS ds__quarter - , subq_7.ds__year AS ds__year - , subq_7.ds__extract_year AS ds__extract_year - , subq_7.ds__extract_quarter AS ds__extract_quarter - , subq_7.ds__extract_month AS ds__extract_month - , subq_7.ds__extract_day AS ds__extract_day - , subq_7.ds__extract_dow AS ds__extract_dow - , subq_7.ds__extract_doy AS ds__extract_doy - , subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__week AS ds_partitioned__week - , subq_7.ds_partitioned__month AS ds_partitioned__month - , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_7.ds_partitioned__year AS ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_7.paid_at__day AS paid_at__day - , subq_7.paid_at__week AS paid_at__week - , subq_7.paid_at__month AS paid_at__month - , subq_7.paid_at__quarter AS paid_at__quarter - , subq_7.paid_at__year AS paid_at__year - , subq_7.paid_at__extract_year AS paid_at__extract_year - , subq_7.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_7.paid_at__extract_month AS paid_at__extract_month - , subq_7.paid_at__extract_day AS paid_at__extract_day - , subq_7.paid_at__extract_dow AS paid_at__extract_dow - , subq_7.paid_at__extract_doy AS paid_at__extract_doy - , subq_7.booking__ds__day AS booking__ds__day - , subq_7.booking__ds__week AS booking__ds__week - , subq_7.booking__ds__month AS booking__ds__month - , subq_7.booking__ds__quarter AS booking__ds__quarter - , subq_7.booking__ds__year AS booking__ds__year - , subq_7.booking__ds__extract_year AS booking__ds__extract_year - , subq_7.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_7.booking__ds__extract_month AS booking__ds__extract_month - , subq_7.booking__ds__extract_day AS booking__ds__extract_day - , subq_7.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_7.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day AS booking__paid_at__day - , subq_7.booking__paid_at__week AS booking__paid_at__week - , subq_7.booking__paid_at__month AS booking__paid_at__month - , subq_7.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_7.booking__paid_at__year AS booking__paid_at__year - , subq_7.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_7.listing AS listing - , subq_7.guest AS guest - , subq_7.host AS host - , subq_7.booking__listing AS booking__listing - , subq_7.booking__guest AS booking__guest - , subq_7.booking__host AS booking__host - , subq_7.is_instant AS is_instant - , subq_7.booking__is_instant AS booking__is_instant - , subq_7.bookings AS bookings - , subq_7.instant_bookings AS instant_bookings - , subq_7.booking_value AS booking_value - , subq_7.max_booking_value AS max_booking_value - , subq_7.min_booking_value AS min_booking_value - , subq_7.bookers AS bookers - , subq_7.average_booking_value AS average_booking_value - , subq_7.referred_bookings AS referred_bookings - , subq_7.median_booking_value AS median_booking_value - , subq_7.booking_value_p99 AS booking_value_p99 - , subq_7.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_17.metric_time__day AS metric_time__day + , subq_16.ds__day AS ds__day + , subq_16.ds__week AS ds__week + , subq_16.ds__month AS ds__month + , subq_16.ds__quarter AS ds__quarter + , subq_16.ds__year AS ds__year + , subq_16.ds__extract_year AS ds__extract_year + , subq_16.ds__extract_quarter AS ds__extract_quarter + , subq_16.ds__extract_month AS ds__extract_month + , subq_16.ds__extract_day AS ds__extract_day + , subq_16.ds__extract_dow AS ds__extract_dow + , subq_16.ds__extract_doy AS ds__extract_doy + , subq_16.ds_partitioned__day AS ds_partitioned__day + , subq_16.ds_partitioned__week AS ds_partitioned__week + , subq_16.ds_partitioned__month AS ds_partitioned__month + , subq_16.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_16.ds_partitioned__year AS ds_partitioned__year + , subq_16.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_16.paid_at__day AS paid_at__day + , subq_16.paid_at__week AS paid_at__week + , subq_16.paid_at__month AS paid_at__month + , subq_16.paid_at__quarter AS paid_at__quarter + , subq_16.paid_at__year AS paid_at__year + , subq_16.paid_at__extract_year AS paid_at__extract_year + , subq_16.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_16.paid_at__extract_month AS paid_at__extract_month + , subq_16.paid_at__extract_day AS paid_at__extract_day + , subq_16.paid_at__extract_dow AS paid_at__extract_dow + , subq_16.paid_at__extract_doy AS paid_at__extract_doy + , subq_16.booking__ds__day AS booking__ds__day + , subq_16.booking__ds__week AS booking__ds__week + , subq_16.booking__ds__month AS booking__ds__month + , subq_16.booking__ds__quarter AS booking__ds__quarter + , subq_16.booking__ds__year AS booking__ds__year + , subq_16.booking__ds__extract_year AS booking__ds__extract_year + , subq_16.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_16.booking__ds__extract_month AS booking__ds__extract_month + , subq_16.booking__ds__extract_day AS booking__ds__extract_day + , subq_16.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_16.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day AS booking__paid_at__day + , subq_16.booking__paid_at__week AS booking__paid_at__week + , subq_16.booking__paid_at__month AS booking__paid_at__month + , subq_16.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_16.booking__paid_at__year AS booking__paid_at__year + , subq_16.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_16.listing AS listing + , subq_16.guest AS guest + , subq_16.host AS host + , subq_16.booking__listing AS booking__listing + , subq_16.booking__guest AS booking__guest + , subq_16.booking__host AS booking__host + , subq_16.is_instant AS is_instant + , subq_16.booking__is_instant AS booking__is_instant + , subq_16.bookings AS bookings + , subq_16.instant_bookings AS instant_bookings + , subq_16.booking_value AS booking_value + , subq_16.max_booking_value AS max_booking_value + , subq_16.min_booking_value AS min_booking_value + , subq_16.bookers AS bookers + , subq_16.average_booking_value AS average_booking_value + , subq_16.referred_bookings AS referred_bookings + , subq_16.median_booking_value AS median_booking_value + , subq_16.booking_value_p99 AS booking_value_p99 + , subq_16.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_16.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - ) subq_8 + subq_18.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + ) subq_17 INNER JOIN ( -- 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_15.ds__day + , subq_15.ds__week + , subq_15.ds__month + , subq_15.ds__quarter + , subq_15.ds__year + , subq_15.ds__extract_year + , subq_15.ds__extract_quarter + , subq_15.ds__extract_month + , subq_15.ds__extract_day + , subq_15.ds__extract_dow + , subq_15.ds__extract_doy + , subq_15.ds_partitioned__day + , subq_15.ds_partitioned__week + , subq_15.ds_partitioned__month + , subq_15.ds_partitioned__quarter + , subq_15.ds_partitioned__year + , subq_15.ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy + , subq_15.paid_at__day + , subq_15.paid_at__week + , subq_15.paid_at__month + , subq_15.paid_at__quarter + , subq_15.paid_at__year + , subq_15.paid_at__extract_year + , subq_15.paid_at__extract_quarter + , subq_15.paid_at__extract_month + , subq_15.paid_at__extract_day + , subq_15.paid_at__extract_dow + , subq_15.paid_at__extract_doy + , subq_15.booking__ds__day + , subq_15.booking__ds__week + , subq_15.booking__ds__month + , subq_15.booking__ds__quarter + , subq_15.booking__ds__year + , subq_15.booking__ds__extract_year + , subq_15.booking__ds__extract_quarter + , subq_15.booking__ds__extract_month + , subq_15.booking__ds__extract_day + , subq_15.booking__ds__extract_dow + , subq_15.booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day + , subq_15.booking__paid_at__week + , subq_15.booking__paid_at__month + , subq_15.booking__paid_at__quarter + , subq_15.booking__paid_at__year + , subq_15.booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy + , subq_15.ds__day AS metric_time__day + , subq_15.ds__week AS metric_time__week + , subq_15.ds__month AS metric_time__month + , subq_15.ds__quarter AS metric_time__quarter + , subq_15.ds__year AS metric_time__year + , subq_15.ds__extract_year AS metric_time__extract_year + , subq_15.ds__extract_quarter AS metric_time__extract_quarter + , subq_15.ds__extract_month AS metric_time__extract_month + , subq_15.ds__extract_day AS metric_time__extract_day + , subq_15.ds__extract_dow AS metric_time__extract_dow + , subq_15.ds__extract_doy AS metric_time__extract_doy + , subq_15.listing + , subq_15.guest + , subq_15.host + , subq_15.booking__listing + , subq_15.booking__guest + , subq_15.booking__host + , subq_15.is_instant + , subq_15.booking__is_instant + , subq_15.bookings + , subq_15.instant_bookings + , subq_15.booking_value + , subq_15.max_booking_value + , subq_15.min_booking_value + , subq_15.bookers + , subq_15.average_booking_value + , subq_15.referred_bookings + , subq_15.median_booking_value + , subq_15.booking_value_p99 + , subq_15.discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 + , subq_15.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 - ) subq_7 + , 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_15 + ) subq_16 ON - DATEADD(day, -14, subq_8.metric_time__day) = subq_7.metric_time__day - ) subq_10 - ) subq_11 + DATEADD(day, -14, subq_17.metric_time__day) = subq_16.metric_time__day + ) subq_19 + ) subq_20 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_12 + ) subq_21 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_21.metric_time__day + ) subq_22 + ) subq_23 ON - subq_5.metric_time__day = subq_14.metric_time__day + subq_14.metric_time__day = subq_23.metric_time__day GROUP BY - COALESCE(subq_5.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_14.metric_time__day, subq_23.metric_time__day) +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 526089b4ce..e4dc96227a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_21.bookings) AS bookings - , MAX(subq_30.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_30.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_30.bookings) AS bookings + , MAX(subq_39.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -22,12 +22,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_21 + ) subq_30 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -39,26 +39,26 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_25.ds AS metric_time__day - , subq_23.bookings AS bookings - FROM ***************************.mf_time_spine subq_25 + subq_34.ds AS metric_time__day + , subq_32.bookings AS bookings + FROM ***************************.mf_time_spine subq_34 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 ON - DATEADD(day, -14, subq_25.ds) = subq_23.metric_time__day - ) subq_27 + DATEADD(day, -14, subq_34.ds) = subq_32.metric_time__day + ) subq_36 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_30 + ) subq_39 ON - subq_21.metric_time__day = subq_30.metric_time__day + subq_30.metric_time__day = subq_39.metric_time__day GROUP BY - COALESCE(subq_21.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_30.metric_time__day, subq_39.metric_time__day) +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql index b1a5656c3f..851a5c1403 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql @@ -1,433 +1,433 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookers AS every_2_days_bookers_2_days_ago + subq_18.metric_time__day + , subq_18.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , COUNT(DISTINCT subq_8.bookers) AS bookers + subq_17.metric_time__day + , COUNT(DISTINCT subq_17.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -2, subq_11.metric_time__day) ) - ) subq_4 + ) subq_13 ON - DATEADD(day, -2, subq_5.metric_time__day) = subq_4.metric_time__day - ) subq_7 - ) subq_8 + DATEADD(day, -2, subq_14.metric_time__day) = subq_13.metric_time__day + ) subq_16 + ) subq_17 GROUP BY - subq_8.metric_time__day - ) subq_9 -) subq_10 + subq_17.metric_time__day + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0_optimized.sql index 866ba0a41b..d5e3a9771e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -8,26 +8,26 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , COUNT(DISTINCT subq_15.bookers) AS every_2_days_bookers_2_days_ago - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , COUNT(DISTINCT subq_24.bookers) AS every_2_days_bookers_2_days_ago + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_14.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_14 + subq_23.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_23 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_23.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATEADD(day, -2, subq_14.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_23.ds) ) - ) subq_15 + ) subq_24 ON - DATEADD(day, -2, subq_17.ds) = subq_15.metric_time__day + DATEADD(day, -2, subq_26.ds) = subq_24.metric_time__day GROUP BY - subq_17.ds -) subq_21 + subq_26.ds +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0.sql index 626adce121..25cb9e8e6d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_7.booking_value) AS booking_value - , MAX(subq_12.bookers) AS bookers + COALESCE(subq_16.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_16.booking_value) AS booking_value + , MAX(subq_21.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_6.booking__ds__day - , subq_6.booking_value + subq_15.booking__ds__day + , subq_15.booking_value FROM ( -- Aggregate Measures SELECT - subq_5.booking__ds__day - , SUM(subq_5.booking_value) AS booking_value + subq_14.booking__ds__day + , SUM(subq_14.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__ds__day'] SELECT - subq_4.booking__ds__day - , subq_4.booking_value + subq_13.booking__ds__day + , subq_13.booking_value FROM ( -- Join to Time Spine Dataset SELECT - subq_2.booking__ds__day AS booking__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.booking__ds__day AS booking__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(week, -1, subq_2.booking__ds__day) = subq_1.booking__ds__day - ) subq_4 - ) subq_5 + DATEADD(week, -1, subq_11.booking__ds__day) = subq_10.booking__ds__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.booking__ds__day - ) subq_6 - ) subq_7 + subq_14.booking__ds__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookers + subq_20.booking__ds__day + , subq_20.bookers FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , COUNT(DISTINCT subq_10.bookers) AS bookers + subq_19.booking__ds__day + , COUNT(DISTINCT subq_19.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookers + subq_18.booking__ds__day + , subq_18.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 - ) subq_10 + , 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_17 + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_7.booking__ds__day = subq_12.booking__ds__day + subq_16.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_7.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_16.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql index 085c58e4f4..0edb7a0c7b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql @@ -5,25 +5,25 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_21.booking_value) AS booking_value - , MAX(subq_26.bookers) AS bookers + COALESCE(subq_30.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_30.booking_value) AS booking_value + , MAX(subq_35.bookers) AS bookers FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['booking_value', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS booking__ds__day - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS booking__ds__day + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.mf_time_spine subq_26 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_17.ds) = DATE_TRUNC('day', bookings_source_src_28001.ds) + DATEADD(week, -1, subq_26.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds - ) subq_21 + subq_26.ds + ) subq_30 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -33,12 +33,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , COUNT(DISTINCT guest_id) AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_26 + ) subq_35 ON - subq_21.booking__ds__day = subq_26.booking__ds__day + subq_30.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_21.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_30.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql index 4093b6845c..dd2d49776b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -1,319 +1,319 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 -) subq_7 + subq_14.metric_time__day + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 56f1d26f59..1a6402a3bb 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -8,19 +8,19 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago + FROM ***************************.mf_time_spine subq_20 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - DATEADD(day, -5, subq_11.ds) = subq_9.metric_time__day + DATEADD(day, -5, subq_20.ds) = subq_18.metric_time__day GROUP BY - subq_11.ds -) subq_15 + subq_20.ds +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0.sql index 3552f891cc..eb50990558 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0.sql @@ -1,895 +1,895 @@ -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day + subq_31.metric_time__day , non_referred + (instant * 1.0 / bookings) AS instant_plus_non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) AS metric_time__day - , MAX(subq_11.non_referred) AS non_referred - , MAX(subq_16.instant) AS instant - , MAX(subq_21.bookings) AS bookings + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day + , MAX(subq_20.non_referred) AS non_referred + , MAX(subq_25.instant) AS instant + , MAX(subq_30.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_16.metric_time__day + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) - ) subq_10 - ) subq_11 + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day - , subq_15.instant_bookings AS instant + subq_24.metric_time__day + , subq_24.instant_bookings AS instant FROM ( -- Aggregate Measures SELECT - subq_14.metric_time__day - , SUM(subq_14.instant_bookings) AS instant_bookings + subq_23.metric_time__day + , SUM(subq_23.instant_bookings) AS instant_bookings FROM ( -- Pass Only Elements: ['instant_bookings', 'metric_time__day'] SELECT - subq_13.metric_time__day - , subq_13.instant_bookings + subq_22.metric_time__day + , subq_22.instant_bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 GROUP BY - subq_14.metric_time__day - ) subq_15 - ) subq_16 + subq_23.metric_time__day + ) subq_24 + ) subq_25 ON - subq_11.metric_time__day = subq_16.metric_time__day + subq_20.metric_time__day = subq_25.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Aggregate Measures SELECT - subq_19.metric_time__day - , SUM(subq_19.bookings) AS bookings + subq_28.metric_time__day + , SUM(subq_28.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.bookings + subq_27.metric_time__day + , subq_27.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_17.ds__day - , subq_17.ds__week - , subq_17.ds__month - , subq_17.ds__quarter - , subq_17.ds__year - , subq_17.ds__extract_year - , subq_17.ds__extract_quarter - , subq_17.ds__extract_month - , subq_17.ds__extract_day - , subq_17.ds__extract_dow - , subq_17.ds__extract_doy - , subq_17.ds_partitioned__day - , subq_17.ds_partitioned__week - , subq_17.ds_partitioned__month - , subq_17.ds_partitioned__quarter - , subq_17.ds_partitioned__year - , subq_17.ds_partitioned__extract_year - , subq_17.ds_partitioned__extract_quarter - , subq_17.ds_partitioned__extract_month - , subq_17.ds_partitioned__extract_day - , subq_17.ds_partitioned__extract_dow - , subq_17.ds_partitioned__extract_doy - , subq_17.paid_at__day - , subq_17.paid_at__week - , subq_17.paid_at__month - , subq_17.paid_at__quarter - , subq_17.paid_at__year - , subq_17.paid_at__extract_year - , subq_17.paid_at__extract_quarter - , subq_17.paid_at__extract_month - , subq_17.paid_at__extract_day - , subq_17.paid_at__extract_dow - , subq_17.paid_at__extract_doy - , subq_17.booking__ds__day - , subq_17.booking__ds__week - , subq_17.booking__ds__month - , subq_17.booking__ds__quarter - , subq_17.booking__ds__year - , subq_17.booking__ds__extract_year - , subq_17.booking__ds__extract_quarter - , subq_17.booking__ds__extract_month - , subq_17.booking__ds__extract_day - , subq_17.booking__ds__extract_dow - , subq_17.booking__ds__extract_doy - , subq_17.booking__ds_partitioned__day - , subq_17.booking__ds_partitioned__week - , subq_17.booking__ds_partitioned__month - , subq_17.booking__ds_partitioned__quarter - , subq_17.booking__ds_partitioned__year - , subq_17.booking__ds_partitioned__extract_year - , subq_17.booking__ds_partitioned__extract_quarter - , subq_17.booking__ds_partitioned__extract_month - , subq_17.booking__ds_partitioned__extract_day - , subq_17.booking__ds_partitioned__extract_dow - , subq_17.booking__ds_partitioned__extract_doy - , subq_17.booking__paid_at__day - , subq_17.booking__paid_at__week - , subq_17.booking__paid_at__month - , subq_17.booking__paid_at__quarter - , subq_17.booking__paid_at__year - , subq_17.booking__paid_at__extract_year - , subq_17.booking__paid_at__extract_quarter - , subq_17.booking__paid_at__extract_month - , subq_17.booking__paid_at__extract_day - , subq_17.booking__paid_at__extract_dow - , subq_17.booking__paid_at__extract_doy - , subq_17.ds__day AS metric_time__day - , subq_17.ds__week AS metric_time__week - , subq_17.ds__month AS metric_time__month - , subq_17.ds__quarter AS metric_time__quarter - , subq_17.ds__year AS metric_time__year - , subq_17.ds__extract_year AS metric_time__extract_year - , subq_17.ds__extract_quarter AS metric_time__extract_quarter - , subq_17.ds__extract_month AS metric_time__extract_month - , subq_17.ds__extract_day AS metric_time__extract_day - , subq_17.ds__extract_dow AS metric_time__extract_dow - , subq_17.ds__extract_doy AS metric_time__extract_doy - , subq_17.listing - , subq_17.guest - , subq_17.host - , subq_17.booking__listing - , subq_17.booking__guest - , subq_17.booking__host - , subq_17.is_instant - , subq_17.booking__is_instant - , subq_17.bookings - , subq_17.instant_bookings - , subq_17.booking_value - , subq_17.max_booking_value - , subq_17.min_booking_value - , subq_17.bookers - , subq_17.average_booking_value - , subq_17.referred_bookings - , subq_17.median_booking_value - , subq_17.booking_value_p99 - , subq_17.discrete_booking_value_p99 - , subq_17.approximate_continuous_booking_value_p99 - , subq_17.approximate_discrete_booking_value_p99 + subq_26.ds__day + , subq_26.ds__week + , subq_26.ds__month + , subq_26.ds__quarter + , subq_26.ds__year + , subq_26.ds__extract_year + , subq_26.ds__extract_quarter + , subq_26.ds__extract_month + , subq_26.ds__extract_day + , subq_26.ds__extract_dow + , subq_26.ds__extract_doy + , subq_26.ds_partitioned__day + , subq_26.ds_partitioned__week + , subq_26.ds_partitioned__month + , subq_26.ds_partitioned__quarter + , subq_26.ds_partitioned__year + , subq_26.ds_partitioned__extract_year + , subq_26.ds_partitioned__extract_quarter + , subq_26.ds_partitioned__extract_month + , subq_26.ds_partitioned__extract_day + , subq_26.ds_partitioned__extract_dow + , subq_26.ds_partitioned__extract_doy + , subq_26.paid_at__day + , subq_26.paid_at__week + , subq_26.paid_at__month + , subq_26.paid_at__quarter + , subq_26.paid_at__year + , subq_26.paid_at__extract_year + , subq_26.paid_at__extract_quarter + , subq_26.paid_at__extract_month + , subq_26.paid_at__extract_day + , subq_26.paid_at__extract_dow + , subq_26.paid_at__extract_doy + , subq_26.booking__ds__day + , subq_26.booking__ds__week + , subq_26.booking__ds__month + , subq_26.booking__ds__quarter + , subq_26.booking__ds__year + , subq_26.booking__ds__extract_year + , subq_26.booking__ds__extract_quarter + , subq_26.booking__ds__extract_month + , subq_26.booking__ds__extract_day + , subq_26.booking__ds__extract_dow + , subq_26.booking__ds__extract_doy + , subq_26.booking__ds_partitioned__day + , subq_26.booking__ds_partitioned__week + , subq_26.booking__ds_partitioned__month + , subq_26.booking__ds_partitioned__quarter + , subq_26.booking__ds_partitioned__year + , subq_26.booking__ds_partitioned__extract_year + , subq_26.booking__ds_partitioned__extract_quarter + , subq_26.booking__ds_partitioned__extract_month + , subq_26.booking__ds_partitioned__extract_day + , subq_26.booking__ds_partitioned__extract_dow + , subq_26.booking__ds_partitioned__extract_doy + , subq_26.booking__paid_at__day + , subq_26.booking__paid_at__week + , subq_26.booking__paid_at__month + , subq_26.booking__paid_at__quarter + , subq_26.booking__paid_at__year + , subq_26.booking__paid_at__extract_year + , subq_26.booking__paid_at__extract_quarter + , subq_26.booking__paid_at__extract_month + , subq_26.booking__paid_at__extract_day + , subq_26.booking__paid_at__extract_dow + , subq_26.booking__paid_at__extract_doy + , subq_26.ds__day AS metric_time__day + , subq_26.ds__week AS metric_time__week + , subq_26.ds__month AS metric_time__month + , subq_26.ds__quarter AS metric_time__quarter + , subq_26.ds__year AS metric_time__year + , subq_26.ds__extract_year AS metric_time__extract_year + , subq_26.ds__extract_quarter AS metric_time__extract_quarter + , subq_26.ds__extract_month AS metric_time__extract_month + , subq_26.ds__extract_day AS metric_time__extract_day + , subq_26.ds__extract_dow AS metric_time__extract_dow + , subq_26.ds__extract_doy AS metric_time__extract_doy + , subq_26.listing + , subq_26.guest + , subq_26.host + , subq_26.booking__listing + , subq_26.booking__guest + , subq_26.booking__host + , subq_26.is_instant + , subq_26.booking__is_instant + , subq_26.bookings + , subq_26.instant_bookings + , subq_26.booking_value + , subq_26.max_booking_value + , subq_26.min_booking_value + , subq_26.bookers + , subq_26.average_booking_value + , subq_26.referred_bookings + , subq_26.median_booking_value + , subq_26.booking_value_p99 + , subq_26.discrete_booking_value_p99 + , subq_26.approximate_continuous_booking_value_p99 + , subq_26.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_17 - ) subq_18 - ) subq_19 + , 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_26 + ) subq_27 + ) subq_28 GROUP BY - subq_19.metric_time__day - ) subq_20 - ) subq_21 + subq_28.metric_time__day + ) subq_29 + ) subq_30 ON - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day) = subq_21.metric_time__day + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day) = subq_30.metric_time__day GROUP BY - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) -) subq_22 + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day, subq_30.metric_time__day) +) subq_31 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0_optimized.sql index 78837fdd96..da1e9fdd5a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) AS metric_time__day - , MAX(subq_34.non_referred) AS non_referred - , MAX(subq_39.instant) AS instant - , MAX(subq_44.bookings) AS bookings + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day, subq_53.metric_time__day) AS metric_time__day + , MAX(subq_43.non_referred) AS non_referred + , MAX(subq_48.instant) AS instant + , MAX(subq_53.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -17,9 +17,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.ref_bookings) AS ref_bookings - , MAX(subq_32.bookings) AS bookings + COALESCE(subq_36.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_36.ref_bookings) AS ref_bookings + , MAX(subq_41.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -33,11 +33,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_25 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_34 GROUP BY metric_time__day - ) subq_27 + ) subq_36 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -51,17 +51,17 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_30 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_39 GROUP BY metric_time__day - ) subq_32 + ) subq_41 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_36.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) - ) subq_33 - ) subq_34 + COALESCE(subq_36.metric_time__day, subq_41.metric_time__day) + ) subq_42 + ) subq_43 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -75,13 +75,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_37 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_46 GROUP BY metric_time__day - ) subq_39 + ) subq_48 ON - subq_34.metric_time__day = subq_39.metric_time__day + subq_43.metric_time__day = subq_48.metric_time__day FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -95,13 +95,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_42 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_51 GROUP BY metric_time__day - ) subq_44 + ) subq_53 ON - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day) = subq_44.metric_time__day + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day) = subq_53.metric_time__day GROUP BY - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) -) subq_45 + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day, subq_53.metric_time__day) +) subq_54 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index ded26bc259..d7b7936597 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -1,359 +1,359 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Pass Only Elements: ['metric_time__day', 'bookings_offset_once'] SELECT - subq_12.metric_time__day - , subq_12.bookings_offset_once + subq_21.metric_time__day + , subq_21.bookings_offset_once FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.booking__is_instant - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.booking__is_instant + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.booking__is_instant AS booking__is_instant - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.booking__is_instant AS booking__is_instant + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant + subq_16.metric_time__day + , subq_16.booking__is_instant , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.bookings + subq_15.metric_time__day + , subq_15.booking__is_instant + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , subq_14.booking__is_instant + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_13.metric_time__day + , subq_13.booking__is_instant + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - , subq_5.booking__is_instant - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + , subq_14.booking__is_instant + ) subq_15 + ) subq_16 + ) subq_17 ON - DATEADD(day, -2, subq_9.metric_time__day) = subq_8.metric_time__day - ) subq_11 + DATEADD(day, -2, subq_18.metric_time__day) = subq_17.metric_time__day + ) subq_20 WHERE booking__is_instant - ) subq_12 -) subq_13 + ) subq_21 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index 611927c9a2..558939c098 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -11,10 +11,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_24.ds AS metric_time__day - , subq_22.booking__is_instant AS booking__is_instant - , subq_22.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_24 + subq_33.ds AS metric_time__day + , subq_31.booking__is_instant AS booking__is_instant + , subq_31.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_33 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -27,10 +27,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , subq_15.booking__is_instant AS booking__is_instant - , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , subq_24.booking__is_instant AS booking__is_instant + , SUM(subq_24.bookings) AS bookings + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -38,17 +38,17 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 ON - DATEADD(day, -5, subq_17.ds) = subq_15.metric_time__day + DATEADD(day, -5, subq_26.ds) = subq_24.metric_time__day GROUP BY - subq_17.ds - , subq_15.booking__is_instant - ) subq_21 - ) subq_22 + subq_26.ds + , subq_24.booking__is_instant + ) subq_30 + ) subq_31 ON - DATEADD(day, -2, subq_24.ds) = subq_22.metric_time__day - ) subq_25 + DATEADD(day, -2, subq_33.ds) = subq_31.metric_time__day + ) subq_34 WHERE booking__is_instant -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql index b0fa998f59..8188abfa75 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql @@ -1,471 +1,471 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , booking_fees - booking_fees_start_of_month AS booking_fees_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_8.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_8.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_14.booking_fees) AS booking_fees + COALESCE(subq_17.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_17.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_23.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.booking_fees_start_of_month AS booking_fees_start_of_month + subq_15.metric_time__day AS metric_time__day + , subq_14.booking_fees_start_of_month AS booking_fees_start_of_month FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_6 + subq_16.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + ) subq_15 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day + subq_13.metric_time__day , booking_value * 0.05 AS booking_fees_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.booking_value) AS booking_value + subq_11.metric_time__day + , SUM(subq_11.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 - ) subq_5 + subq_11.metric_time__day + ) subq_12 + ) subq_13 + ) subq_14 ON - DATE_TRUNC('month', subq_6.metric_time__day) = subq_5.metric_time__day - ) subq_8 + DATE_TRUNC('month', subq_15.metric_time__day) = subq_14.metric_time__day + ) subq_17 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , booking_value * 0.05 AS booking_fees FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value + subq_21.metric_time__day + , subq_21.booking_value FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_20.metric_time__day + , SUM(subq_20.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_19.metric_time__day + , subq_19.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__extract_quarter - , subq_9.ds__extract_month - , subq_9.ds__extract_day - , subq_9.ds__extract_dow - , subq_9.ds__extract_doy - , subq_9.ds_partitioned__day - , subq_9.ds_partitioned__week - , subq_9.ds_partitioned__month - , subq_9.ds_partitioned__quarter - , subq_9.ds_partitioned__year - , subq_9.ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy - , subq_9.paid_at__day - , subq_9.paid_at__week - , subq_9.paid_at__month - , subq_9.paid_at__quarter - , subq_9.paid_at__year - , subq_9.paid_at__extract_year - , subq_9.paid_at__extract_quarter - , subq_9.paid_at__extract_month - , subq_9.paid_at__extract_day - , subq_9.paid_at__extract_dow - , subq_9.paid_at__extract_doy - , subq_9.booking__ds__day - , subq_9.booking__ds__week - , subq_9.booking__ds__month - , subq_9.booking__ds__quarter - , subq_9.booking__ds__year - , subq_9.booking__ds__extract_year - , subq_9.booking__ds__extract_quarter - , subq_9.booking__ds__extract_month - , subq_9.booking__ds__extract_day - , subq_9.booking__ds__extract_dow - , subq_9.booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day - , subq_9.booking__paid_at__week - , subq_9.booking__paid_at__month - , subq_9.booking__paid_at__quarter - , subq_9.booking__paid_at__year - , subq_9.booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy - , subq_9.ds__day AS metric_time__day - , subq_9.ds__week AS metric_time__week - , subq_9.ds__month AS metric_time__month - , subq_9.ds__quarter AS metric_time__quarter - , subq_9.ds__year AS metric_time__year - , subq_9.ds__extract_year AS metric_time__extract_year - , subq_9.ds__extract_quarter AS metric_time__extract_quarter - , subq_9.ds__extract_month AS metric_time__extract_month - , subq_9.ds__extract_day AS metric_time__extract_day - , subq_9.ds__extract_dow AS metric_time__extract_dow - , subq_9.ds__extract_doy AS metric_time__extract_doy - , subq_9.listing - , subq_9.guest - , subq_9.host - , subq_9.booking__listing - , subq_9.booking__guest - , subq_9.booking__host - , subq_9.is_instant - , subq_9.booking__is_instant - , subq_9.bookings - , subq_9.instant_bookings - , subq_9.booking_value - , subq_9.max_booking_value - , subq_9.min_booking_value - , subq_9.bookers - , subq_9.average_booking_value - , subq_9.referred_bookings - , subq_9.median_booking_value - , subq_9.booking_value_p99 - , subq_9.discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 + 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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 - ) subq_10 - ) subq_11 + , 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_18 + ) subq_19 + ) subq_20 GROUP BY - subq_11.metric_time__day - ) subq_12 - ) subq_13 - ) subq_14 + subq_20.metric_time__day + ) subq_21 + ) subq_22 + ) subq_23 ON - subq_8.metric_time__day = subq_14.metric_time__day + subq_17.metric_time__day = subq_23.metric_time__day GROUP BY - COALESCE(subq_8.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_17.metric_time__day, subq_23.metric_time__day) +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql index fc648c54b6..b28105f311 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_24.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_30.booking_fees) AS booking_fees + COALESCE(subq_33.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_33.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_39.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.booking_fees_start_of_month AS booking_fees_start_of_month - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.booking_fees_start_of_month AS booking_fees_start_of_month + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,14 +28,14 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 ON - DATE_TRUNC('month', subq_23.ds) = subq_21.metric_time__day - ) subq_24 + DATE_TRUNC('month', subq_32.ds) = subq_30.metric_time__day + ) subq_33 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT @@ -50,13 +50,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_29 - ) subq_30 + ) subq_38 + ) subq_39 ON - subq_24.metric_time__day = subq_30.metric_time__day + subq_33.metric_time__day = subq_39.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_33.metric_time__day, subq_39.metric_time__day) +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0.sql index eac718f93e..aff0c63eff 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0.sql @@ -8,991 +8,991 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_30.booking_value) AS booking_value + MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.average_booking_value + subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_9.average_booking_value) AS average_booking_value + AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_8.average_booking_value + subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.booking__is_instant + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.booking__is_instant + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value 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_2.average_booking_value AS average_booking_value + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.average_booking_value + subq_10.listing + , subq_10.booking__is_instant + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_8 - ) subq_9 - ) subq_10 - ) subq_11 + ) subq_17 + ) subq_18 + ) subq_19 + ) subq_20 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.bookings + subq_31.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_21.bookings) AS bookings + SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_20.bookings + subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.booking__is_instant - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.booking__is_instant + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_18.booking__is_instant - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.listing AS listing - , subq_14.booking__is_instant AS booking__is_instant - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.listing AS listing + , subq_23.booking__is_instant AS booking__is_instant + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_13.listing - , subq_13.booking__is_instant - , subq_13.bookings + subq_22.listing + , subq_22.booking__is_instant + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_20 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_29 + ) subq_30 + ) subq_31 + ) subq_32 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_29.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_28.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_27.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 -) subq_32 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0_optimized.sql index 14649c62dd..35859d3713 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0_optimized.sql +++ b/metricflow/test/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_44.average_booking_value) AS average_booking_value - , MAX(subq_56.bookings) AS bookings - , MAX(subq_63.booking_value) AS booking_value + MAX(subq_53.average_booking_value) AS average_booking_value + , MAX(subq_65.bookings) AS bookings + , MAX(subq_72.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,17 +22,17 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - bookings_source_src_28001.is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_40 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_49 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_44 + ) subq_53 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -44,9 +44,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_47.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_47.bookings AS bookings + subq_56.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_56.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -55,15 +55,15 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_47 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_56 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_47.listing = listings_latest_src_28005.listing_id - ) subq_52 + subq_56.listing = listings_latest_src_28000.listing_id + ) subq_61 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_56 + ) subq_65 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -78,9 +78,9 @@ FROM ( SELECT is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_59 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_68 WHERE booking__is_instant - ) subq_63 - ) subq_64 -) subq_65 + ) subq_72 + ) subq_73 +) subq_74 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0.sql index 3cc6820071..9f0e348418 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0.sql @@ -1,339 +1,339 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - DATEADD(day, -2, subq_9.metric_time__day) = subq_8.metric_time__day -) subq_11 + DATEADD(day, -2, subq_18.metric_time__day) = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0_optimized.sql index e9df61ae2f..a1458a856e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -19,23 +19,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - DATEADD(day, -5, subq_15.ds) = subq_13.metric_time__day + DATEADD(day, -5, subq_24.ds) = subq_22.metric_time__day GROUP BY - subq_15.ds - ) subq_19 - ) subq_20 + subq_24.ds + ) subq_28 + ) subq_29 ON - DATEADD(day, -2, subq_22.ds) = subq_20.metric_time__day -) subq_23 + DATEADD(day, -2, subq_31.ds) = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0.sql index b94d38afb3..8b521664ea 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0.sql @@ -1,340 +1,340 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - WHERE subq_10.ds BETWEEN '2020-01-12' AND '2020-01-13' - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + WHERE subq_19.ds BETWEEN '2020-01-12' AND '2020-01-13' + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - DATEADD(day, -2, subq_9.metric_time__day) = subq_8.metric_time__day -) subq_11 + DATEADD(day, -2, subq_18.metric_time__day) = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 82beb8296d..ce05de9f1e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_21.metric_time__day AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once + subq_30.metric_time__day AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_22 + FROM ***************************.mf_time_spine subq_31 WHERE ds BETWEEN '2020-01-12' AND '2020-01-13' - ) subq_21 + ) subq_30 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -25,23 +25,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - DATEADD(day, -5, subq_15.ds) = subq_13.metric_time__day + DATEADD(day, -5, subq_24.ds) = subq_22.metric_time__day GROUP BY - subq_15.ds - ) subq_19 - ) subq_20 + subq_24.ds + ) subq_28 + ) subq_29 ON - DATEADD(day, -2, subq_21.metric_time__day) = subq_20.metric_time__day -) subq_23 + DATEADD(day, -2, subq_30.metric_time__day) = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0.sql index db15a1e982..87e05d640e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0.sql @@ -1,346 +1,346 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day + subq_21.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - DATEADD(day, -2, subq_9.metric_time__day) = subq_8.metric_time__day - ) subq_11 + DATEADD(day, -2, subq_18.metric_time__day) = subq_17.metric_time__day + ) subq_20 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_12 +) subq_21 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0_optimized.sql index e17438d2ae..533c803d41 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -10,9 +10,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,25 +24,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.ds AS metric_time__day - , SUM(subq_14.bookings) AS bookings - FROM ***************************.mf_time_spine subq_16 + subq_25.ds AS metric_time__day + , SUM(subq_23.bookings) AS bookings + FROM ***************************.mf_time_spine subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_14 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_23 ON - DATEADD(day, -5, subq_16.ds) = subq_14.metric_time__day + DATEADD(day, -5, subq_25.ds) = subq_23.metric_time__day GROUP BY - subq_16.ds - ) subq_20 - ) subq_21 + subq_25.ds + ) subq_29 + ) subq_30 ON - DATEADD(day, -2, subq_23.ds) = subq_21.metric_time__day - ) subq_24 + DATEADD(day, -2, subq_32.ds) = subq_30.metric_time__day + ) subq_33 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_25 +) subq_34 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0.sql index 4d62ef95b3..4984b94ddc 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__ds__day - ) subq_3 - ) subq_4 + subq_11.booking__ds__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.booking__ds__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.booking__ds__day) = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.booking__ds__day) = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql index 1b7dbc4725..9f6d4b5769 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.booking__ds__day + DATE_TRUNC('month', subq_31.ds) = subq_29.booking__ds__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0.sql index b7ef21c966..0f81d58776 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__ds__day - ) subq_3 - ) subq_4 + subq_11.booking__ds__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.booking__ds__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATEADD(day, -14, subq_7.booking__ds__day) = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + DATEADD(day, -14, subq_16.booking__ds__day) = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0_optimized.sql index 272991a8dc..dc58b2992d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATEADD(day, -14, subq_22.ds) = subq_20.booking__ds__day + DATEADD(day, -14, subq_31.ds) = subq_29.booking__ds__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0.sql index 7db0055b6d..2bcc49dc1e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0.sql @@ -1,320 +1,320 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - WHERE subq_3.ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + WHERE subq_12.ds BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 -) subq_7 + subq_14.metric_time__day + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0_optimized.sql index ee1dcbf475..f3a30decfa 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -8,25 +8,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago + subq_19.metric_time__day AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_20 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_10 + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - DATEADD(day, -5, subq_10.metric_time__day) = subq_9.metric_time__day + DATEADD(day, -5, subq_19.metric_time__day) = subq_18.metric_time__day GROUP BY - subq_10.metric_time__day -) subq_15 + subq_19.metric_time__day +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index dce7659bbc..88727e99da 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -1,441 +1,441 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.bookers AS every_2_days_bookers_2_days_ago + subq_19.metric_time__day + , subq_19.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , COUNT(DISTINCT subq_9.bookers) AS bookers + subq_18.metric_time__day + , COUNT(DISTINCT subq_18.bookers) AS bookers FROM ( -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] SELECT - subq_8.metric_time__day - , subq_8.bookers + subq_17.metric_time__day + , subq_17.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > subq_2.metric_time__day - INTERVAL 2 day + subq_10.metric_time__day > subq_11.metric_time__day - INTERVAL 2 day ) - ) subq_4 + ) subq_13 ON - subq_5.metric_time__day - INTERVAL 2 day = subq_4.metric_time__day - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_9 + subq_14.metric_time__day - INTERVAL 2 day = subq_13.metric_time__day + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 -) subq_11 + subq_18.metric_time__day + ) subq_19 +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index 7412a7d091..a60bc4a0e3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -9,33 +9,33 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day AS metric_time__day - , COUNT(DISTINCT subq_16.bookers) AS every_2_days_bookers_2_days_ago + subq_26.metric_time__day AS metric_time__day + , COUNT(DISTINCT subq_25.bookers) AS every_2_days_bookers_2_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_18 + FROM ***************************.mf_time_spine subq_27 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_17 + ) subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_15.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_24 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_15.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_24.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > subq_15.ds - INTERVAL 2 day + DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_24.ds - INTERVAL 2 day ) - ) subq_16 + ) subq_25 ON - subq_17.metric_time__day - INTERVAL 2 day = subq_16.metric_time__day - WHERE subq_17.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' + subq_26.metric_time__day - INTERVAL 2 day = subq_25.metric_time__day + WHERE subq_26.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' GROUP BY - subq_17.metric_time__day -) subq_23 + subq_26.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0.sql index ea8a884590..7d019a0866 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0.sql @@ -1,445 +1,445 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_16.metric_time__day + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) -) subq_10 + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0_optimized.sql index 23f7234c6e..1638560b4d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , MAX(subq_15.ref_bookings) AS ref_bookings - , MAX(subq_20.bookings) AS bookings + COALESCE(subq_24.metric_time__day, subq_29.metric_time__day) AS metric_time__day + , MAX(subq_24.ref_bookings) AS ref_bookings + , MAX(subq_29.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,11 +21,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 GROUP BY metric_time__day - ) subq_15 + ) subq_24 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,13 +39,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_15.metric_time__day = subq_20.metric_time__day + subq_24.metric_time__day = subq_29.metric_time__day GROUP BY - COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) -) subq_21 + COALESCE(subq_24.metric_time__day, subq_29.metric_time__day) +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 243d2d1af4..8cdf29bee8 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -1,73 +1,73 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__month + subq_9.metric_time__month , bookings_last_month AS bookings_last_month FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly AS bookings_last_month + subq_8.metric_time__month + , subq_8.bookings_monthly AS bookings_last_month FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__month - , SUM(subq_5.bookings_monthly) AS bookings_monthly + subq_7.metric_time__month + , SUM(subq_7.bookings_monthly) AS bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_4.metric_time__month - , subq_4.bookings_monthly + subq_6.metric_time__month + , subq_6.bookings_monthly FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__month AS metric_time__month - , subq_1.monthly_ds__month AS monthly_ds__month - , subq_1.monthly_ds__quarter AS monthly_ds__quarter - , subq_1.monthly_ds__year AS monthly_ds__year - , subq_1.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_1.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_1.listing AS listing - , subq_1.booking__listing AS booking__listing - , subq_1.bookings_monthly AS bookings_monthly + subq_4.metric_time__month AS metric_time__month + , subq_3.monthly_ds__month AS monthly_ds__month + , subq_3.monthly_ds__quarter AS monthly_ds__quarter + , subq_3.monthly_ds__year AS monthly_ds__year + , subq_3.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_3.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_3.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_3.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_3.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_3.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_3.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_3.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_3.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_3.listing AS listing + , subq_3.booking__listing AS booking__listing + , subq_3.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_3.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_3 + DATE_TRUNC('month', subq_5.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_5 GROUP BY - DATE_TRUNC('month', subq_3.ds) - ) subq_2 + DATE_TRUNC('month', subq_5.ds) + ) subq_4 INNER JOIN ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_2.monthly_ds__month + , subq_2.monthly_ds__quarter + , subq_2.monthly_ds__year + , subq_2.monthly_ds__extract_year + , subq_2.monthly_ds__extract_quarter + , subq_2.monthly_ds__extract_month + , subq_2.booking__monthly_ds__month + , subq_2.booking__monthly_ds__quarter + , subq_2.booking__monthly_ds__year + , subq_2.booking__monthly_ds__extract_year + , subq_2.booking__monthly_ds__extract_quarter + , subq_2.booking__monthly_ds__extract_month + , subq_2.monthly_ds__month AS metric_time__month + , subq_2.monthly_ds__quarter AS metric_time__quarter + , subq_2.monthly_ds__year AS metric_time__year + , subq_2.monthly_ds__extract_year AS metric_time__extract_year + , subq_2.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_2.monthly_ds__extract_month AS metric_time__extract_month + , subq_2.listing + , subq_2.booking__listing + , subq_2.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -87,13 +87,13 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 + ) subq_2 + ) subq_3 ON - subq_2.metric_time__month - INTERVAL 1 month = subq_1.metric_time__month - ) subq_4 - ) subq_5 + subq_4.metric_time__month - INTERVAL 1 month = subq_3.metric_time__month + ) subq_6 + ) subq_7 GROUP BY - subq_5.metric_time__month - ) subq_6 -) subq_7 + subq_7.metric_time__month + ) subq_8 +) subq_9 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index 9e93cbb724..85d84cf924 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -8,20 +8,20 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month AS metric_time__month + subq_12.metric_time__month AS metric_time__month , SUM(bookings_monthly_source_src_16000.bookings_monthly) AS bookings_last_month FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_13 GROUP BY DATE_TRUNC('month', ds) - ) subq_10 + ) subq_12 INNER JOIN ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 ON - subq_10.metric_time__month - INTERVAL 1 month = DATE_TRUNC('month', bookings_monthly_source_src_16000.ds) + subq_12.metric_time__month - INTERVAL 1 month = DATE_TRUNC('month', bookings_monthly_source_src_16000.ds) GROUP BY - subq_10.metric_time__month -) subq_15 + subq_12.metric_time__month +) subq_17 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql index 7128b81a47..05bcafad18 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__day - ) subq_11 - ) subq_12 + subq_19.metric_time__day + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) -) subq_13 + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 5138fe8ae6..2061be23cf 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day + DATE_TRUNC('month', subq_31.ds) = subq_29.metric_time__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) -) subq_27 + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index a18f1a3e30..a8b56fb822 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -1,546 +1,546 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__week + subq_22.metric_time__week , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) AS metric_time__week - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__week, subq_21.metric_time__week) AS metric_time__week + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__week - , subq_3.bookings + subq_12.metric_time__week + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__week - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__week + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_1.metric_time__week - , subq_1.bookings + subq_10.metric_time__week + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__week - ) subq_3 - ) subq_4 + subq_11.metric_time__week + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__week - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__week + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__week - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__week + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_9.metric_time__week - , subq_9.bookings + subq_18.metric_time__week + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('week', subq_7.metric_time__day) AS metric_time__week - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('week', subq_16.metric_time__day) AS metric_time__week + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.metric_time__day) = subq_6.metric_time__day - WHERE DATE_TRUNC('week', subq_7.metric_time__day) = subq_7.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.metric_time__day) = subq_15.metric_time__day + WHERE DATE_TRUNC('week', subq_16.metric_time__day) = subq_16.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__week - ) subq_11 - ) subq_12 + subq_19.metric_time__week + ) subq_20 + ) subq_21 ON - subq_4.metric_time__week = subq_12.metric_time__week + subq_13.metric_time__week = subq_21.metric_time__week GROUP BY - COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) -) subq_13 + COALESCE(subq_13.metric_time__week, subq_21.metric_time__week) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index b9e4162413..65cf132abd 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) AS metric_time__week - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__week, subq_35.metric_time__week) AS metric_time__week + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,36 +21,36 @@ FROM ( SELECT DATE_TRUNC('week', ds) AS metric_time__week , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__week - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__week'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('week', subq_22.ds) AS metric_time__week - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC('week', subq_31.ds) AS metric_time__week + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day - WHERE DATE_TRUNC('week', subq_22.ds) = subq_22.ds + DATE_TRUNC('month', subq_31.ds) = subq_29.metric_time__day + WHERE DATE_TRUNC('week', subq_31.ds) = subq_31.ds GROUP BY - DATE_TRUNC('week', subq_22.ds) - ) subq_26 + DATE_TRUNC('week', subq_31.ds) + ) subq_35 ON - subq_18.metric_time__week = subq_26.metric_time__week + subq_27.metric_time__week = subq_35.metric_time__week GROUP BY - COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) -) subq_27 + COALESCE(subq_27.metric_time__week, subq_35.metric_time__week) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql index c04aa961af..60c82383cd 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - subq_7.metric_time__day - INTERVAL 14 day = subq_6.metric_time__day - ) subq_9 - ) subq_10 + subq_16.metric_time__day - INTERVAL 14 day = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__day - ) subq_11 - ) subq_12 + subq_19.metric_time__day + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) -) subq_13 + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0_optimized.sql index b92618b957..08216bb7af 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - subq_22.ds - INTERVAL 14 day = subq_20.metric_time__day + subq_31.ds - INTERVAL 14 day = subq_29.metric_time__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) -) subq_27 + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql index bd5832637c..26f7f0dad2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__quarter + subq_22.metric_time__quarter , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) AS metric_time__quarter - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__quarter, subq_21.metric_time__quarter) AS metric_time__quarter + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__quarter - , subq_3.bookings + subq_12.metric_time__quarter + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__quarter - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__quarter + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_1.metric_time__quarter - , subq_1.bookings + subq_10.metric_time__quarter + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__quarter - ) subq_3 - ) subq_4 + subq_11.metric_time__quarter + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__quarter - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__quarter + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__quarter - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__quarter + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_9.metric_time__quarter - , subq_9.bookings + subq_18.metric_time__quarter + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('quarter', subq_7.metric_time__day) AS metric_time__quarter - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('quarter', subq_16.metric_time__day) AS metric_time__quarter + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - subq_7.metric_time__day - INTERVAL 14 day = subq_6.metric_time__day - ) subq_9 - ) subq_10 + subq_16.metric_time__day - INTERVAL 14 day = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__quarter - ) subq_11 - ) subq_12 + subq_19.metric_time__quarter + ) subq_20 + ) subq_21 ON - subq_4.metric_time__quarter = subq_12.metric_time__quarter + subq_13.metric_time__quarter = subq_21.metric_time__quarter GROUP BY - COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) -) subq_13 + COALESCE(subq_13.metric_time__quarter, subq_21.metric_time__quarter) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index 02b4702e42..58825b9649 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) AS metric_time__quarter - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__quarter, subq_35.metric_time__quarter) AS metric_time__quarter + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('quarter', ds) AS metric_time__quarter , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__quarter - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__quarter'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('quarter', subq_22.ds) AS metric_time__quarter - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC('quarter', subq_31.ds) AS metric_time__quarter + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - subq_22.ds - INTERVAL 14 day = subq_20.metric_time__day + subq_31.ds - INTERVAL 14 day = subq_29.metric_time__day GROUP BY - DATE_TRUNC('quarter', subq_22.ds) - ) subq_26 + DATE_TRUNC('quarter', subq_31.ds) + ) subq_35 ON - subq_18.metric_time__quarter = subq_26.metric_time__quarter + subq_27.metric_time__quarter = subq_35.metric_time__quarter GROUP BY - COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) -) subq_27 + COALESCE(subq_27.metric_time__quarter, subq_35.metric_time__quarter) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 22d0da11b5..d5fa59df6b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -1,645 +1,645 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__day + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC('month', subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 + subq_14.metric_time__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - subq_10.metric_time__day - INTERVAL 1 month = subq_9.metric_time__day - ) subq_12 - ) subq_13 + subq_19.metric_time__day - INTERVAL 1 month = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__day - ) subq_14 - ) subq_15 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) -) subq_16 + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index d93f426343..7e4f903640 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -5,55 +5,55 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_20.ds AS metric_time__day - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + subq_29.ds AS metric_time__day + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day + DATE_TRUNC('month', subq_29.ds) = subq_27.metric_time__day GROUP BY - subq_20.ds - ) subq_24 + subq_29.ds + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - subq_28.ds - INTERVAL 1 month = subq_26.metric_time__day + subq_37.ds - INTERVAL 1 month = subq_35.metric_time__day GROUP BY - subq_28.ds - ) subq_32 + subq_37.ds + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 5cb9811632..60d78ffb7c 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -1,646 +1,646 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__year + subq_25.metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) AS metric_time__year - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__year, subq_24.metric_time__year) AS metric_time__year + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__year - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__year + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__year - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__year + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_4.metric_time__year - , subq_4.bookings + subq_13.metric_time__year + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('year', subq_11.metric_time__day) AS metric_time__year + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - WHERE DATE_TRUNC('year', subq_2.metric_time__day) = subq_2.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC('month', subq_11.metric_time__day) = subq_10.metric_time__day + WHERE DATE_TRUNC('year', subq_11.metric_time__day) = subq_11.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__year - ) subq_6 - ) subq_7 + subq_14.metric_time__year + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__year - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__year + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__year - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__year + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_12.metric_time__year - , subq_12.bookings + subq_21.metric_time__year + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_10.metric_time__day) AS metric_time__year - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('year', subq_19.metric_time__day) AS metric_time__year + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - subq_10.metric_time__day - INTERVAL 1 month = subq_9.metric_time__day - ) subq_12 - ) subq_13 + subq_19.metric_time__day - INTERVAL 1 month = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__year - ) subq_14 - ) subq_15 + subq_22.metric_time__year + ) subq_23 + ) subq_24 ON - subq_7.metric_time__year = subq_15.metric_time__year + subq_16.metric_time__year = subq_24.metric_time__year GROUP BY - COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) -) subq_16 + COALESCE(subq_16.metric_time__year, subq_24.metric_time__year) +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index b302d98946..cc8d63e4bc 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,56 +5,56 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) AS metric_time__year - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__year, subq_41.metric_time__year) AS metric_time__year + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_20.ds) AS metric_time__year - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + DATE_TRUNC('year', subq_29.ds) AS metric_time__year + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day - WHERE DATE_TRUNC('year', subq_20.ds) = subq_20.ds + DATE_TRUNC('month', subq_29.ds) = subq_27.metric_time__day + WHERE DATE_TRUNC('year', subq_29.ds) = subq_29.ds GROUP BY - DATE_TRUNC('year', subq_20.ds) - ) subq_24 + DATE_TRUNC('year', subq_29.ds) + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_28.ds) AS metric_time__year - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + DATE_TRUNC('year', subq_37.ds) AS metric_time__year + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - subq_28.ds - INTERVAL 1 month = subq_26.metric_time__day + subq_37.ds - INTERVAL 1 month = subq_35.metric_time__day GROUP BY - DATE_TRUNC('year', subq_28.ds) - ) subq_32 + DATE_TRUNC('year', subq_37.ds) + ) subq_41 ON - subq_24.metric_time__year = subq_32.metric_time__year + subq_33.metric_time__year = subq_41.metric_time__year GROUP BY - COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) -) subq_33 + COALESCE(subq_33.metric_time__year, subq_41.metric_time__year) +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 75b7558130..3d4f5e0b6a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_5.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_5.bookings) AS bookings - , MAX(subq_14.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_14.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_14.bookings) AS bookings + , MAX(subq_23.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_3.metric_time__day - , SUM(subq_3.bookings) AS bookings + subq_12.metric_time__day + , SUM(subq_12.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.bookings + subq_11.metric_time__day + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_3 + ) subq_12 GROUP BY - subq_3.metric_time__day - ) subq_4 - ) subq_5 + subq_12.metric_time__day + ) subq_13 + ) subq_14 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.bookings AS bookings_2_weeks_ago + subq_22.metric_time__day + , subq_22.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.bookings) AS bookings + subq_21.metric_time__day + , SUM(subq_21.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings + subq_20.metric_time__day + , subq_20.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_19.metric_time__day + , subq_19.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.ds__day AS ds__day - , subq_7.ds__week AS ds__week - , subq_7.ds__month AS ds__month - , subq_7.ds__quarter AS ds__quarter - , subq_7.ds__year AS ds__year - , subq_7.ds__extract_year AS ds__extract_year - , subq_7.ds__extract_quarter AS ds__extract_quarter - , subq_7.ds__extract_month AS ds__extract_month - , subq_7.ds__extract_day AS ds__extract_day - , subq_7.ds__extract_dow AS ds__extract_dow - , subq_7.ds__extract_doy AS ds__extract_doy - , subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__week AS ds_partitioned__week - , subq_7.ds_partitioned__month AS ds_partitioned__month - , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_7.ds_partitioned__year AS ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_7.paid_at__day AS paid_at__day - , subq_7.paid_at__week AS paid_at__week - , subq_7.paid_at__month AS paid_at__month - , subq_7.paid_at__quarter AS paid_at__quarter - , subq_7.paid_at__year AS paid_at__year - , subq_7.paid_at__extract_year AS paid_at__extract_year - , subq_7.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_7.paid_at__extract_month AS paid_at__extract_month - , subq_7.paid_at__extract_day AS paid_at__extract_day - , subq_7.paid_at__extract_dow AS paid_at__extract_dow - , subq_7.paid_at__extract_doy AS paid_at__extract_doy - , subq_7.booking__ds__day AS booking__ds__day - , subq_7.booking__ds__week AS booking__ds__week - , subq_7.booking__ds__month AS booking__ds__month - , subq_7.booking__ds__quarter AS booking__ds__quarter - , subq_7.booking__ds__year AS booking__ds__year - , subq_7.booking__ds__extract_year AS booking__ds__extract_year - , subq_7.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_7.booking__ds__extract_month AS booking__ds__extract_month - , subq_7.booking__ds__extract_day AS booking__ds__extract_day - , subq_7.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_7.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day AS booking__paid_at__day - , subq_7.booking__paid_at__week AS booking__paid_at__week - , subq_7.booking__paid_at__month AS booking__paid_at__month - , subq_7.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_7.booking__paid_at__year AS booking__paid_at__year - , subq_7.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_7.listing AS listing - , subq_7.guest AS guest - , subq_7.host AS host - , subq_7.booking__listing AS booking__listing - , subq_7.booking__guest AS booking__guest - , subq_7.booking__host AS booking__host - , subq_7.is_instant AS is_instant - , subq_7.booking__is_instant AS booking__is_instant - , subq_7.bookings AS bookings - , subq_7.instant_bookings AS instant_bookings - , subq_7.booking_value AS booking_value - , subq_7.max_booking_value AS max_booking_value - , subq_7.min_booking_value AS min_booking_value - , subq_7.bookers AS bookers - , subq_7.average_booking_value AS average_booking_value - , subq_7.referred_bookings AS referred_bookings - , subq_7.median_booking_value AS median_booking_value - , subq_7.booking_value_p99 AS booking_value_p99 - , subq_7.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_17.metric_time__day AS metric_time__day + , subq_16.ds__day AS ds__day + , subq_16.ds__week AS ds__week + , subq_16.ds__month AS ds__month + , subq_16.ds__quarter AS ds__quarter + , subq_16.ds__year AS ds__year + , subq_16.ds__extract_year AS ds__extract_year + , subq_16.ds__extract_quarter AS ds__extract_quarter + , subq_16.ds__extract_month AS ds__extract_month + , subq_16.ds__extract_day AS ds__extract_day + , subq_16.ds__extract_dow AS ds__extract_dow + , subq_16.ds__extract_doy AS ds__extract_doy + , subq_16.ds_partitioned__day AS ds_partitioned__day + , subq_16.ds_partitioned__week AS ds_partitioned__week + , subq_16.ds_partitioned__month AS ds_partitioned__month + , subq_16.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_16.ds_partitioned__year AS ds_partitioned__year + , subq_16.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_16.paid_at__day AS paid_at__day + , subq_16.paid_at__week AS paid_at__week + , subq_16.paid_at__month AS paid_at__month + , subq_16.paid_at__quarter AS paid_at__quarter + , subq_16.paid_at__year AS paid_at__year + , subq_16.paid_at__extract_year AS paid_at__extract_year + , subq_16.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_16.paid_at__extract_month AS paid_at__extract_month + , subq_16.paid_at__extract_day AS paid_at__extract_day + , subq_16.paid_at__extract_dow AS paid_at__extract_dow + , subq_16.paid_at__extract_doy AS paid_at__extract_doy + , subq_16.booking__ds__day AS booking__ds__day + , subq_16.booking__ds__week AS booking__ds__week + , subq_16.booking__ds__month AS booking__ds__month + , subq_16.booking__ds__quarter AS booking__ds__quarter + , subq_16.booking__ds__year AS booking__ds__year + , subq_16.booking__ds__extract_year AS booking__ds__extract_year + , subq_16.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_16.booking__ds__extract_month AS booking__ds__extract_month + , subq_16.booking__ds__extract_day AS booking__ds__extract_day + , subq_16.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_16.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day AS booking__paid_at__day + , subq_16.booking__paid_at__week AS booking__paid_at__week + , subq_16.booking__paid_at__month AS booking__paid_at__month + , subq_16.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_16.booking__paid_at__year AS booking__paid_at__year + , subq_16.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_16.listing AS listing + , subq_16.guest AS guest + , subq_16.host AS host + , subq_16.booking__listing AS booking__listing + , subq_16.booking__guest AS booking__guest + , subq_16.booking__host AS booking__host + , subq_16.is_instant AS is_instant + , subq_16.booking__is_instant AS booking__is_instant + , subq_16.bookings AS bookings + , subq_16.instant_bookings AS instant_bookings + , subq_16.booking_value AS booking_value + , subq_16.max_booking_value AS max_booking_value + , subq_16.min_booking_value AS min_booking_value + , subq_16.bookers AS bookers + , subq_16.average_booking_value AS average_booking_value + , subq_16.referred_bookings AS referred_bookings + , subq_16.median_booking_value AS median_booking_value + , subq_16.booking_value_p99 AS booking_value_p99 + , subq_16.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_16.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - ) subq_8 + subq_18.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + ) subq_17 INNER JOIN ( -- 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_15.ds__day + , subq_15.ds__week + , subq_15.ds__month + , subq_15.ds__quarter + , subq_15.ds__year + , subq_15.ds__extract_year + , subq_15.ds__extract_quarter + , subq_15.ds__extract_month + , subq_15.ds__extract_day + , subq_15.ds__extract_dow + , subq_15.ds__extract_doy + , subq_15.ds_partitioned__day + , subq_15.ds_partitioned__week + , subq_15.ds_partitioned__month + , subq_15.ds_partitioned__quarter + , subq_15.ds_partitioned__year + , subq_15.ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy + , subq_15.paid_at__day + , subq_15.paid_at__week + , subq_15.paid_at__month + , subq_15.paid_at__quarter + , subq_15.paid_at__year + , subq_15.paid_at__extract_year + , subq_15.paid_at__extract_quarter + , subq_15.paid_at__extract_month + , subq_15.paid_at__extract_day + , subq_15.paid_at__extract_dow + , subq_15.paid_at__extract_doy + , subq_15.booking__ds__day + , subq_15.booking__ds__week + , subq_15.booking__ds__month + , subq_15.booking__ds__quarter + , subq_15.booking__ds__year + , subq_15.booking__ds__extract_year + , subq_15.booking__ds__extract_quarter + , subq_15.booking__ds__extract_month + , subq_15.booking__ds__extract_day + , subq_15.booking__ds__extract_dow + , subq_15.booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day + , subq_15.booking__paid_at__week + , subq_15.booking__paid_at__month + , subq_15.booking__paid_at__quarter + , subq_15.booking__paid_at__year + , subq_15.booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy + , subq_15.ds__day AS metric_time__day + , subq_15.ds__week AS metric_time__week + , subq_15.ds__month AS metric_time__month + , subq_15.ds__quarter AS metric_time__quarter + , subq_15.ds__year AS metric_time__year + , subq_15.ds__extract_year AS metric_time__extract_year + , subq_15.ds__extract_quarter AS metric_time__extract_quarter + , subq_15.ds__extract_month AS metric_time__extract_month + , subq_15.ds__extract_day AS metric_time__extract_day + , subq_15.ds__extract_dow AS metric_time__extract_dow + , subq_15.ds__extract_doy AS metric_time__extract_doy + , subq_15.listing + , subq_15.guest + , subq_15.host + , subq_15.booking__listing + , subq_15.booking__guest + , subq_15.booking__host + , subq_15.is_instant + , subq_15.booking__is_instant + , subq_15.bookings + , subq_15.instant_bookings + , subq_15.booking_value + , subq_15.max_booking_value + , subq_15.min_booking_value + , subq_15.bookers + , subq_15.average_booking_value + , subq_15.referred_bookings + , subq_15.median_booking_value + , subq_15.booking_value_p99 + , subq_15.discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 + , subq_15.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 - ) subq_7 + , 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_15 + ) subq_16 ON - subq_8.metric_time__day - INTERVAL 14 day = subq_7.metric_time__day - ) subq_10 - ) subq_11 + subq_17.metric_time__day - INTERVAL 14 day = subq_16.metric_time__day + ) subq_19 + ) subq_20 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_12 + ) subq_21 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_21.metric_time__day + ) subq_22 + ) subq_23 ON - subq_5.metric_time__day = subq_14.metric_time__day + subq_14.metric_time__day = subq_23.metric_time__day GROUP BY - COALESCE(subq_5.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_14.metric_time__day, subq_23.metric_time__day) +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 4cb0fa5704..f05040d692 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_21.bookings) AS bookings - , MAX(subq_30.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_30.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_30.bookings) AS bookings + , MAX(subq_39.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -22,12 +22,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_21 + ) subq_30 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -39,26 +39,26 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_25.ds AS metric_time__day - , subq_23.bookings AS bookings - FROM ***************************.mf_time_spine subq_25 + subq_34.ds AS metric_time__day + , subq_32.bookings AS bookings + FROM ***************************.mf_time_spine subq_34 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 ON - subq_25.ds - INTERVAL 14 day = subq_23.metric_time__day - ) subq_27 + subq_34.ds - INTERVAL 14 day = subq_32.metric_time__day + ) subq_36 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_30 + ) subq_39 ON - subq_21.metric_time__day = subq_30.metric_time__day + subq_30.metric_time__day = subq_39.metric_time__day GROUP BY - COALESCE(subq_21.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_30.metric_time__day, subq_39.metric_time__day) +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql index 5af1f633e1..08bbc28c5c 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql @@ -1,433 +1,433 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookers AS every_2_days_bookers_2_days_ago + subq_18.metric_time__day + , subq_18.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , COUNT(DISTINCT subq_8.bookers) AS bookers + subq_17.metric_time__day + , COUNT(DISTINCT subq_17.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > subq_2.metric_time__day - INTERVAL 2 day + subq_10.metric_time__day > subq_11.metric_time__day - INTERVAL 2 day ) - ) subq_4 + ) subq_13 ON - subq_5.metric_time__day - INTERVAL 2 day = subq_4.metric_time__day - ) subq_7 - ) subq_8 + subq_14.metric_time__day - INTERVAL 2 day = subq_13.metric_time__day + ) subq_16 + ) subq_17 GROUP BY - subq_8.metric_time__day - ) subq_9 -) subq_10 + subq_17.metric_time__day + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0_optimized.sql index e2ce4906a7..9570b597eb 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -8,26 +8,26 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , COUNT(DISTINCT subq_15.bookers) AS every_2_days_bookers_2_days_ago - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , COUNT(DISTINCT subq_24.bookers) AS every_2_days_bookers_2_days_ago + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_14.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_14 + subq_23.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_23 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_23.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > subq_14.ds - INTERVAL 2 day + DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_23.ds - INTERVAL 2 day ) - ) subq_15 + ) subq_24 ON - subq_17.ds - INTERVAL 2 day = subq_15.metric_time__day + subq_26.ds - INTERVAL 2 day = subq_24.metric_time__day GROUP BY - subq_17.ds -) subq_21 + subq_26.ds +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0.sql index 7ba9d4567b..ee3f39c019 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_7.booking_value) AS booking_value - , MAX(subq_12.bookers) AS bookers + COALESCE(subq_16.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_16.booking_value) AS booking_value + , MAX(subq_21.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_6.booking__ds__day - , subq_6.booking_value + subq_15.booking__ds__day + , subq_15.booking_value FROM ( -- Aggregate Measures SELECT - subq_5.booking__ds__day - , SUM(subq_5.booking_value) AS booking_value + subq_14.booking__ds__day + , SUM(subq_14.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__ds__day'] SELECT - subq_4.booking__ds__day - , subq_4.booking_value + subq_13.booking__ds__day + , subq_13.booking_value FROM ( -- Join to Time Spine Dataset SELECT - subq_2.booking__ds__day AS booking__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.booking__ds__day AS booking__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.booking__ds__day - INTERVAL 1 week = subq_1.booking__ds__day - ) subq_4 - ) subq_5 + subq_11.booking__ds__day - INTERVAL 1 week = subq_10.booking__ds__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.booking__ds__day - ) subq_6 - ) subq_7 + subq_14.booking__ds__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookers + subq_20.booking__ds__day + , subq_20.bookers FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , COUNT(DISTINCT subq_10.bookers) AS bookers + subq_19.booking__ds__day + , COUNT(DISTINCT subq_19.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookers + subq_18.booking__ds__day + , subq_18.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 - ) subq_10 + , 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_17 + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_7.booking__ds__day = subq_12.booking__ds__day + subq_16.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_7.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_16.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql index 61c03608e8..7c864f3209 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql @@ -5,25 +5,25 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_21.booking_value) AS booking_value - , MAX(subq_26.bookers) AS bookers + COALESCE(subq_30.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_30.booking_value) AS booking_value + , MAX(subq_35.bookers) AS bookers FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['booking_value', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS booking__ds__day - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS booking__ds__day + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.mf_time_spine subq_26 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON - subq_17.ds - INTERVAL 1 week = DATE_TRUNC('day', bookings_source_src_28001.ds) + subq_26.ds - INTERVAL 1 week = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds - ) subq_21 + subq_26.ds + ) subq_30 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -33,12 +33,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , COUNT(DISTINCT guest_id) AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_26 + ) subq_35 ON - subq_21.booking__ds__day = subq_26.booking__ds__day + subq_30.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_21.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_30.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql index fbba0c8a66..3db62ba55d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -1,319 +1,319 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.metric_time__day - INTERVAL 5 day = subq_1.metric_time__day - ) subq_4 - ) subq_5 + subq_11.metric_time__day - INTERVAL 5 day = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 -) subq_7 + subq_14.metric_time__day + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index c2a635c12c..d073016d0d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -8,19 +8,19 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago + FROM ***************************.mf_time_spine subq_20 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - subq_11.ds - INTERVAL 5 day = subq_9.metric_time__day + subq_20.ds - INTERVAL 5 day = subq_18.metric_time__day GROUP BY - subq_11.ds -) subq_15 + subq_20.ds +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0.sql index 2d28d5feb7..7918ef7e73 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0.sql @@ -1,895 +1,895 @@ -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day + subq_31.metric_time__day , non_referred + (instant * 1.0 / bookings) AS instant_plus_non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) AS metric_time__day - , MAX(subq_11.non_referred) AS non_referred - , MAX(subq_16.instant) AS instant - , MAX(subq_21.bookings) AS bookings + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day + , MAX(subq_20.non_referred) AS non_referred + , MAX(subq_25.instant) AS instant + , MAX(subq_30.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_16.metric_time__day + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) - ) subq_10 - ) subq_11 + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day - , subq_15.instant_bookings AS instant + subq_24.metric_time__day + , subq_24.instant_bookings AS instant FROM ( -- Aggregate Measures SELECT - subq_14.metric_time__day - , SUM(subq_14.instant_bookings) AS instant_bookings + subq_23.metric_time__day + , SUM(subq_23.instant_bookings) AS instant_bookings FROM ( -- Pass Only Elements: ['instant_bookings', 'metric_time__day'] SELECT - subq_13.metric_time__day - , subq_13.instant_bookings + subq_22.metric_time__day + , subq_22.instant_bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 GROUP BY - subq_14.metric_time__day - ) subq_15 - ) subq_16 + subq_23.metric_time__day + ) subq_24 + ) subq_25 ON - subq_11.metric_time__day = subq_16.metric_time__day + subq_20.metric_time__day = subq_25.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Aggregate Measures SELECT - subq_19.metric_time__day - , SUM(subq_19.bookings) AS bookings + subq_28.metric_time__day + , SUM(subq_28.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.bookings + subq_27.metric_time__day + , subq_27.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_17.ds__day - , subq_17.ds__week - , subq_17.ds__month - , subq_17.ds__quarter - , subq_17.ds__year - , subq_17.ds__extract_year - , subq_17.ds__extract_quarter - , subq_17.ds__extract_month - , subq_17.ds__extract_day - , subq_17.ds__extract_dow - , subq_17.ds__extract_doy - , subq_17.ds_partitioned__day - , subq_17.ds_partitioned__week - , subq_17.ds_partitioned__month - , subq_17.ds_partitioned__quarter - , subq_17.ds_partitioned__year - , subq_17.ds_partitioned__extract_year - , subq_17.ds_partitioned__extract_quarter - , subq_17.ds_partitioned__extract_month - , subq_17.ds_partitioned__extract_day - , subq_17.ds_partitioned__extract_dow - , subq_17.ds_partitioned__extract_doy - , subq_17.paid_at__day - , subq_17.paid_at__week - , subq_17.paid_at__month - , subq_17.paid_at__quarter - , subq_17.paid_at__year - , subq_17.paid_at__extract_year - , subq_17.paid_at__extract_quarter - , subq_17.paid_at__extract_month - , subq_17.paid_at__extract_day - , subq_17.paid_at__extract_dow - , subq_17.paid_at__extract_doy - , subq_17.booking__ds__day - , subq_17.booking__ds__week - , subq_17.booking__ds__month - , subq_17.booking__ds__quarter - , subq_17.booking__ds__year - , subq_17.booking__ds__extract_year - , subq_17.booking__ds__extract_quarter - , subq_17.booking__ds__extract_month - , subq_17.booking__ds__extract_day - , subq_17.booking__ds__extract_dow - , subq_17.booking__ds__extract_doy - , subq_17.booking__ds_partitioned__day - , subq_17.booking__ds_partitioned__week - , subq_17.booking__ds_partitioned__month - , subq_17.booking__ds_partitioned__quarter - , subq_17.booking__ds_partitioned__year - , subq_17.booking__ds_partitioned__extract_year - , subq_17.booking__ds_partitioned__extract_quarter - , subq_17.booking__ds_partitioned__extract_month - , subq_17.booking__ds_partitioned__extract_day - , subq_17.booking__ds_partitioned__extract_dow - , subq_17.booking__ds_partitioned__extract_doy - , subq_17.booking__paid_at__day - , subq_17.booking__paid_at__week - , subq_17.booking__paid_at__month - , subq_17.booking__paid_at__quarter - , subq_17.booking__paid_at__year - , subq_17.booking__paid_at__extract_year - , subq_17.booking__paid_at__extract_quarter - , subq_17.booking__paid_at__extract_month - , subq_17.booking__paid_at__extract_day - , subq_17.booking__paid_at__extract_dow - , subq_17.booking__paid_at__extract_doy - , subq_17.ds__day AS metric_time__day - , subq_17.ds__week AS metric_time__week - , subq_17.ds__month AS metric_time__month - , subq_17.ds__quarter AS metric_time__quarter - , subq_17.ds__year AS metric_time__year - , subq_17.ds__extract_year AS metric_time__extract_year - , subq_17.ds__extract_quarter AS metric_time__extract_quarter - , subq_17.ds__extract_month AS metric_time__extract_month - , subq_17.ds__extract_day AS metric_time__extract_day - , subq_17.ds__extract_dow AS metric_time__extract_dow - , subq_17.ds__extract_doy AS metric_time__extract_doy - , subq_17.listing - , subq_17.guest - , subq_17.host - , subq_17.booking__listing - , subq_17.booking__guest - , subq_17.booking__host - , subq_17.is_instant - , subq_17.booking__is_instant - , subq_17.bookings - , subq_17.instant_bookings - , subq_17.booking_value - , subq_17.max_booking_value - , subq_17.min_booking_value - , subq_17.bookers - , subq_17.average_booking_value - , subq_17.referred_bookings - , subq_17.median_booking_value - , subq_17.booking_value_p99 - , subq_17.discrete_booking_value_p99 - , subq_17.approximate_continuous_booking_value_p99 - , subq_17.approximate_discrete_booking_value_p99 + subq_26.ds__day + , subq_26.ds__week + , subq_26.ds__month + , subq_26.ds__quarter + , subq_26.ds__year + , subq_26.ds__extract_year + , subq_26.ds__extract_quarter + , subq_26.ds__extract_month + , subq_26.ds__extract_day + , subq_26.ds__extract_dow + , subq_26.ds__extract_doy + , subq_26.ds_partitioned__day + , subq_26.ds_partitioned__week + , subq_26.ds_partitioned__month + , subq_26.ds_partitioned__quarter + , subq_26.ds_partitioned__year + , subq_26.ds_partitioned__extract_year + , subq_26.ds_partitioned__extract_quarter + , subq_26.ds_partitioned__extract_month + , subq_26.ds_partitioned__extract_day + , subq_26.ds_partitioned__extract_dow + , subq_26.ds_partitioned__extract_doy + , subq_26.paid_at__day + , subq_26.paid_at__week + , subq_26.paid_at__month + , subq_26.paid_at__quarter + , subq_26.paid_at__year + , subq_26.paid_at__extract_year + , subq_26.paid_at__extract_quarter + , subq_26.paid_at__extract_month + , subq_26.paid_at__extract_day + , subq_26.paid_at__extract_dow + , subq_26.paid_at__extract_doy + , subq_26.booking__ds__day + , subq_26.booking__ds__week + , subq_26.booking__ds__month + , subq_26.booking__ds__quarter + , subq_26.booking__ds__year + , subq_26.booking__ds__extract_year + , subq_26.booking__ds__extract_quarter + , subq_26.booking__ds__extract_month + , subq_26.booking__ds__extract_day + , subq_26.booking__ds__extract_dow + , subq_26.booking__ds__extract_doy + , subq_26.booking__ds_partitioned__day + , subq_26.booking__ds_partitioned__week + , subq_26.booking__ds_partitioned__month + , subq_26.booking__ds_partitioned__quarter + , subq_26.booking__ds_partitioned__year + , subq_26.booking__ds_partitioned__extract_year + , subq_26.booking__ds_partitioned__extract_quarter + , subq_26.booking__ds_partitioned__extract_month + , subq_26.booking__ds_partitioned__extract_day + , subq_26.booking__ds_partitioned__extract_dow + , subq_26.booking__ds_partitioned__extract_doy + , subq_26.booking__paid_at__day + , subq_26.booking__paid_at__week + , subq_26.booking__paid_at__month + , subq_26.booking__paid_at__quarter + , subq_26.booking__paid_at__year + , subq_26.booking__paid_at__extract_year + , subq_26.booking__paid_at__extract_quarter + , subq_26.booking__paid_at__extract_month + , subq_26.booking__paid_at__extract_day + , subq_26.booking__paid_at__extract_dow + , subq_26.booking__paid_at__extract_doy + , subq_26.ds__day AS metric_time__day + , subq_26.ds__week AS metric_time__week + , subq_26.ds__month AS metric_time__month + , subq_26.ds__quarter AS metric_time__quarter + , subq_26.ds__year AS metric_time__year + , subq_26.ds__extract_year AS metric_time__extract_year + , subq_26.ds__extract_quarter AS metric_time__extract_quarter + , subq_26.ds__extract_month AS metric_time__extract_month + , subq_26.ds__extract_day AS metric_time__extract_day + , subq_26.ds__extract_dow AS metric_time__extract_dow + , subq_26.ds__extract_doy AS metric_time__extract_doy + , subq_26.listing + , subq_26.guest + , subq_26.host + , subq_26.booking__listing + , subq_26.booking__guest + , subq_26.booking__host + , subq_26.is_instant + , subq_26.booking__is_instant + , subq_26.bookings + , subq_26.instant_bookings + , subq_26.booking_value + , subq_26.max_booking_value + , subq_26.min_booking_value + , subq_26.bookers + , subq_26.average_booking_value + , subq_26.referred_bookings + , subq_26.median_booking_value + , subq_26.booking_value_p99 + , subq_26.discrete_booking_value_p99 + , subq_26.approximate_continuous_booking_value_p99 + , subq_26.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_17 - ) subq_18 - ) subq_19 + , 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_26 + ) subq_27 + ) subq_28 GROUP BY - subq_19.metric_time__day - ) subq_20 - ) subq_21 + subq_28.metric_time__day + ) subq_29 + ) subq_30 ON - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day) = subq_21.metric_time__day + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day) = subq_30.metric_time__day GROUP BY - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) -) subq_22 + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day, subq_30.metric_time__day) +) subq_31 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0_optimized.sql index 78837fdd96..da1e9fdd5a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) AS metric_time__day - , MAX(subq_34.non_referred) AS non_referred - , MAX(subq_39.instant) AS instant - , MAX(subq_44.bookings) AS bookings + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day, subq_53.metric_time__day) AS metric_time__day + , MAX(subq_43.non_referred) AS non_referred + , MAX(subq_48.instant) AS instant + , MAX(subq_53.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -17,9 +17,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.ref_bookings) AS ref_bookings - , MAX(subq_32.bookings) AS bookings + COALESCE(subq_36.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_36.ref_bookings) AS ref_bookings + , MAX(subq_41.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -33,11 +33,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_25 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_34 GROUP BY metric_time__day - ) subq_27 + ) subq_36 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -51,17 +51,17 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_30 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_39 GROUP BY metric_time__day - ) subq_32 + ) subq_41 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_36.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) - ) subq_33 - ) subq_34 + COALESCE(subq_36.metric_time__day, subq_41.metric_time__day) + ) subq_42 + ) subq_43 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -75,13 +75,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_37 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_46 GROUP BY metric_time__day - ) subq_39 + ) subq_48 ON - subq_34.metric_time__day = subq_39.metric_time__day + subq_43.metric_time__day = subq_48.metric_time__day FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -95,13 +95,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_42 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_51 GROUP BY metric_time__day - ) subq_44 + ) subq_53 ON - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day) = subq_44.metric_time__day + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day) = subq_53.metric_time__day GROUP BY - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) -) subq_45 + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day, subq_53.metric_time__day) +) subq_54 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 8393f42f8f..c8deeee7b2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -1,359 +1,359 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Pass Only Elements: ['metric_time__day', 'bookings_offset_once'] SELECT - subq_12.metric_time__day - , subq_12.bookings_offset_once + subq_21.metric_time__day + , subq_21.bookings_offset_once FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.booking__is_instant - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.booking__is_instant + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.booking__is_instant AS booking__is_instant - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.booking__is_instant AS booking__is_instant + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant + subq_16.metric_time__day + , subq_16.booking__is_instant , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.bookings + subq_15.metric_time__day + , subq_15.booking__is_instant + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , subq_14.booking__is_instant + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_13.metric_time__day + , subq_13.booking__is_instant + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.metric_time__day - INTERVAL 5 day = subq_1.metric_time__day - ) subq_4 - ) subq_5 + subq_11.metric_time__day - INTERVAL 5 day = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - , subq_5.booking__is_instant - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + , subq_14.booking__is_instant + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_9.metric_time__day - INTERVAL 2 day = subq_8.metric_time__day - ) subq_11 + subq_18.metric_time__day - INTERVAL 2 day = subq_17.metric_time__day + ) subq_20 WHERE booking__is_instant - ) subq_12 -) subq_13 + ) subq_21 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index 4cf7ae57ba..30c2b67772 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -11,10 +11,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_24.ds AS metric_time__day - , subq_22.booking__is_instant AS booking__is_instant - , subq_22.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_24 + subq_33.ds AS metric_time__day + , subq_31.booking__is_instant AS booking__is_instant + , subq_31.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_33 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -27,10 +27,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , subq_15.booking__is_instant AS booking__is_instant - , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , subq_24.booking__is_instant AS booking__is_instant + , SUM(subq_24.bookings) AS bookings + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -38,17 +38,17 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 ON - subq_17.ds - INTERVAL 5 day = subq_15.metric_time__day + subq_26.ds - INTERVAL 5 day = subq_24.metric_time__day GROUP BY - subq_17.ds - , subq_15.booking__is_instant - ) subq_21 - ) subq_22 + subq_26.ds + , subq_24.booking__is_instant + ) subq_30 + ) subq_31 ON - subq_24.ds - INTERVAL 2 day = subq_22.metric_time__day - ) subq_25 + subq_33.ds - INTERVAL 2 day = subq_31.metric_time__day + ) subq_34 WHERE booking__is_instant -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql index b6024d9277..36d9bb6cd4 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql @@ -1,471 +1,471 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , booking_fees - booking_fees_start_of_month AS booking_fees_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_8.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_8.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_14.booking_fees) AS booking_fees + COALESCE(subq_17.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_17.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_23.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.booking_fees_start_of_month AS booking_fees_start_of_month + subq_15.metric_time__day AS metric_time__day + , subq_14.booking_fees_start_of_month AS booking_fees_start_of_month FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_6 + subq_16.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + ) subq_15 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day + subq_13.metric_time__day , booking_value * 0.05 AS booking_fees_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.booking_value) AS booking_value + subq_11.metric_time__day + , SUM(subq_11.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 - ) subq_5 + subq_11.metric_time__day + ) subq_12 + ) subq_13 + ) subq_14 ON - DATE_TRUNC('month', subq_6.metric_time__day) = subq_5.metric_time__day - ) subq_8 + DATE_TRUNC('month', subq_15.metric_time__day) = subq_14.metric_time__day + ) subq_17 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , booking_value * 0.05 AS booking_fees FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value + subq_21.metric_time__day + , subq_21.booking_value FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_20.metric_time__day + , SUM(subq_20.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_19.metric_time__day + , subq_19.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__extract_quarter - , subq_9.ds__extract_month - , subq_9.ds__extract_day - , subq_9.ds__extract_dow - , subq_9.ds__extract_doy - , subq_9.ds_partitioned__day - , subq_9.ds_partitioned__week - , subq_9.ds_partitioned__month - , subq_9.ds_partitioned__quarter - , subq_9.ds_partitioned__year - , subq_9.ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy - , subq_9.paid_at__day - , subq_9.paid_at__week - , subq_9.paid_at__month - , subq_9.paid_at__quarter - , subq_9.paid_at__year - , subq_9.paid_at__extract_year - , subq_9.paid_at__extract_quarter - , subq_9.paid_at__extract_month - , subq_9.paid_at__extract_day - , subq_9.paid_at__extract_dow - , subq_9.paid_at__extract_doy - , subq_9.booking__ds__day - , subq_9.booking__ds__week - , subq_9.booking__ds__month - , subq_9.booking__ds__quarter - , subq_9.booking__ds__year - , subq_9.booking__ds__extract_year - , subq_9.booking__ds__extract_quarter - , subq_9.booking__ds__extract_month - , subq_9.booking__ds__extract_day - , subq_9.booking__ds__extract_dow - , subq_9.booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day - , subq_9.booking__paid_at__week - , subq_9.booking__paid_at__month - , subq_9.booking__paid_at__quarter - , subq_9.booking__paid_at__year - , subq_9.booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy - , subq_9.ds__day AS metric_time__day - , subq_9.ds__week AS metric_time__week - , subq_9.ds__month AS metric_time__month - , subq_9.ds__quarter AS metric_time__quarter - , subq_9.ds__year AS metric_time__year - , subq_9.ds__extract_year AS metric_time__extract_year - , subq_9.ds__extract_quarter AS metric_time__extract_quarter - , subq_9.ds__extract_month AS metric_time__extract_month - , subq_9.ds__extract_day AS metric_time__extract_day - , subq_9.ds__extract_dow AS metric_time__extract_dow - , subq_9.ds__extract_doy AS metric_time__extract_doy - , subq_9.listing - , subq_9.guest - , subq_9.host - , subq_9.booking__listing - , subq_9.booking__guest - , subq_9.booking__host - , subq_9.is_instant - , subq_9.booking__is_instant - , subq_9.bookings - , subq_9.instant_bookings - , subq_9.booking_value - , subq_9.max_booking_value - , subq_9.min_booking_value - , subq_9.bookers - , subq_9.average_booking_value - , subq_9.referred_bookings - , subq_9.median_booking_value - , subq_9.booking_value_p99 - , subq_9.discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 + 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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 - ) subq_10 - ) subq_11 + , 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_18 + ) subq_19 + ) subq_20 GROUP BY - subq_11.metric_time__day - ) subq_12 - ) subq_13 - ) subq_14 + subq_20.metric_time__day + ) subq_21 + ) subq_22 + ) subq_23 ON - subq_8.metric_time__day = subq_14.metric_time__day + subq_17.metric_time__day = subq_23.metric_time__day GROUP BY - COALESCE(subq_8.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_17.metric_time__day, subq_23.metric_time__day) +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql index fc648c54b6..b28105f311 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_24.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_30.booking_fees) AS booking_fees + COALESCE(subq_33.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_33.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_39.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.booking_fees_start_of_month AS booking_fees_start_of_month - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.booking_fees_start_of_month AS booking_fees_start_of_month + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,14 +28,14 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 ON - DATE_TRUNC('month', subq_23.ds) = subq_21.metric_time__day - ) subq_24 + DATE_TRUNC('month', subq_32.ds) = subq_30.metric_time__day + ) subq_33 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT @@ -50,13 +50,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_29 - ) subq_30 + ) subq_38 + ) subq_39 ON - subq_24.metric_time__day = subq_30.metric_time__day + subq_33.metric_time__day = subq_39.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_33.metric_time__day, subq_39.metric_time__day) +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0.sql index 25419e889e..dd594f7ee4 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0.sql @@ -8,991 +8,991 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_30.booking_value) AS booking_value + MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.average_booking_value + subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_9.average_booking_value) AS average_booking_value + AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_8.average_booking_value + subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.booking__is_instant + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.booking__is_instant + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value 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_2.average_booking_value AS average_booking_value + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.average_booking_value + subq_10.listing + , subq_10.booking__is_instant + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_8 - ) subq_9 - ) subq_10 - ) subq_11 + ) subq_17 + ) subq_18 + ) subq_19 + ) subq_20 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.bookings + subq_31.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_21.bookings) AS bookings + SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_20.bookings + subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.booking__is_instant - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.booking__is_instant + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_18.booking__is_instant - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.listing AS listing - , subq_14.booking__is_instant AS booking__is_instant - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.listing AS listing + , subq_23.booking__is_instant AS booking__is_instant + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_13.listing - , subq_13.booking__is_instant - , subq_13.bookings + subq_22.listing + , subq_22.booking__is_instant + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_20 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_29 + ) subq_30 + ) subq_31 + ) subq_32 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_29.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_28.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_27.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 -) subq_32 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0_optimized.sql index 14649c62dd..35859d3713 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_44.average_booking_value) AS average_booking_value - , MAX(subq_56.bookings) AS bookings - , MAX(subq_63.booking_value) AS booking_value + MAX(subq_53.average_booking_value) AS average_booking_value + , MAX(subq_65.bookings) AS bookings + , MAX(subq_72.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,17 +22,17 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - bookings_source_src_28001.is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_40 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_49 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_44 + ) subq_53 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -44,9 +44,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_47.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_47.bookings AS bookings + subq_56.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_56.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -55,15 +55,15 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_47 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_56 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_47.listing = listings_latest_src_28005.listing_id - ) subq_52 + subq_56.listing = listings_latest_src_28000.listing_id + ) subq_61 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_56 + ) subq_65 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -78,9 +78,9 @@ FROM ( SELECT is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_59 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_68 WHERE booking__is_instant - ) subq_63 - ) subq_64 -) subq_65 + ) subq_72 + ) subq_73 +) subq_74 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets__plan0.sql index 92db22a335..ac5c92fc90 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets__plan0.sql @@ -1,339 +1,339 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.metric_time__day - INTERVAL 5 day = subq_1.metric_time__day - ) subq_4 - ) subq_5 + subq_11.metric_time__day - INTERVAL 5 day = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_9.metric_time__day - INTERVAL 2 day = subq_8.metric_time__day -) subq_11 + subq_18.metric_time__day - INTERVAL 2 day = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets__plan0_optimized.sql index 2cd763bf76..096c79bece 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -19,23 +19,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - subq_15.ds - INTERVAL 5 day = subq_13.metric_time__day + subq_24.ds - INTERVAL 5 day = subq_22.metric_time__day GROUP BY - subq_15.ds - ) subq_19 - ) subq_20 + subq_24.ds + ) subq_28 + ) subq_29 ON - subq_22.ds - INTERVAL 2 day = subq_20.metric_time__day -) subq_23 + subq_31.ds - INTERVAL 2 day = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0.sql index 192e070ed7..af2064300c 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0.sql @@ -1,340 +1,340 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - WHERE subq_10.ds BETWEEN '2020-01-12' AND '2020-01-13' - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + WHERE subq_19.ds BETWEEN '2020-01-12' AND '2020-01-13' + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.metric_time__day - INTERVAL 5 day = subq_1.metric_time__day - ) subq_4 - ) subq_5 + subq_11.metric_time__day - INTERVAL 5 day = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_9.metric_time__day - INTERVAL 2 day = subq_8.metric_time__day -) subq_11 + subq_18.metric_time__day - INTERVAL 2 day = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0_optimized.sql index af16b573cd..c9d2e86e72 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_21.metric_time__day AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once + subq_30.metric_time__day AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_22 + FROM ***************************.mf_time_spine subq_31 WHERE ds BETWEEN '2020-01-12' AND '2020-01-13' - ) subq_21 + ) subq_30 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -25,23 +25,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - subq_15.ds - INTERVAL 5 day = subq_13.metric_time__day + subq_24.ds - INTERVAL 5 day = subq_22.metric_time__day GROUP BY - subq_15.ds - ) subq_19 - ) subq_20 + subq_24.ds + ) subq_28 + ) subq_29 ON - subq_21.metric_time__day - INTERVAL 2 day = subq_20.metric_time__day -) subq_23 + subq_30.metric_time__day - INTERVAL 2 day = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0.sql index 1a2ce986ce..bcf5b0cc96 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0.sql @@ -1,346 +1,346 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day + subq_21.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.metric_time__day - INTERVAL 5 day = subq_1.metric_time__day - ) subq_4 - ) subq_5 + subq_11.metric_time__day - INTERVAL 5 day = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_9.metric_time__day - INTERVAL 2 day = subq_8.metric_time__day - ) subq_11 + subq_18.metric_time__day - INTERVAL 2 day = subq_17.metric_time__day + ) subq_20 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_12 +) subq_21 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0_optimized.sql index 7fe8fe2dc8..80de5e187c 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -10,9 +10,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,25 +24,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.ds AS metric_time__day - , SUM(subq_14.bookings) AS bookings - FROM ***************************.mf_time_spine subq_16 + subq_25.ds AS metric_time__day + , SUM(subq_23.bookings) AS bookings + FROM ***************************.mf_time_spine subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_14 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_23 ON - subq_16.ds - INTERVAL 5 day = subq_14.metric_time__day + subq_25.ds - INTERVAL 5 day = subq_23.metric_time__day GROUP BY - subq_16.ds - ) subq_20 - ) subq_21 + subq_25.ds + ) subq_29 + ) subq_30 ON - subq_23.ds - INTERVAL 2 day = subq_21.metric_time__day - ) subq_24 + subq_32.ds - INTERVAL 2 day = subq_30.metric_time__day + ) subq_33 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_25 +) subq_34 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0.sql index df42cd08d1..efe0218840 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__ds__day - ) subq_3 - ) subq_4 + subq_11.booking__ds__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.booking__ds__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.booking__ds__day) = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.booking__ds__day) = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql index 1b7dbc4725..9f6d4b5769 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.booking__ds__day + DATE_TRUNC('month', subq_31.ds) = subq_29.booking__ds__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0.sql index 692ba28311..3c4c17e800 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__ds__day - ) subq_3 - ) subq_4 + subq_11.booking__ds__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.booking__ds__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - subq_7.booking__ds__day - INTERVAL 14 day = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + subq_16.booking__ds__day - INTERVAL 14 day = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0_optimized.sql index 7c15aff8a3..8ff4d862e8 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - subq_22.ds - INTERVAL 14 day = subq_20.booking__ds__day + subq_31.ds - INTERVAL 14 day = subq_29.booking__ds__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0.sql index 7c503cf26e..9224ec5199 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0.sql @@ -1,320 +1,320 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - WHERE subq_3.ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + WHERE subq_12.ds BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.metric_time__day - INTERVAL 5 day = subq_1.metric_time__day - ) subq_4 - ) subq_5 + subq_11.metric_time__day - INTERVAL 5 day = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 -) subq_7 + subq_14.metric_time__day + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0_optimized.sql index 0c95d432b8..14d9b3da81 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -8,25 +8,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago + subq_19.metric_time__day AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_20 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_10 + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - subq_10.metric_time__day - INTERVAL 5 day = subq_9.metric_time__day + subq_19.metric_time__day - INTERVAL 5 day = subq_18.metric_time__day GROUP BY - subq_10.metric_time__day -) subq_15 + subq_19.metric_time__day +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index f7f967a868..85539f43d3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -1,441 +1,441 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.bookers AS every_2_days_bookers_2_days_ago + subq_19.metric_time__day + , subq_19.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , COUNT(DISTINCT subq_9.bookers) AS bookers + subq_18.metric_time__day + , COUNT(DISTINCT subq_18.bookers) AS bookers FROM ( -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] SELECT - subq_8.metric_time__day - , subq_8.bookers + subq_17.metric_time__day + , subq_17.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > subq_2.metric_time__day - MAKE_INTERVAL(days => 2) + subq_10.metric_time__day > subq_11.metric_time__day - MAKE_INTERVAL(days => 2) ) - ) subq_4 + ) subq_13 ON - subq_5.metric_time__day - MAKE_INTERVAL(days => 2) = subq_4.metric_time__day - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_9 + subq_14.metric_time__day - MAKE_INTERVAL(days => 2) = subq_13.metric_time__day + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 -) subq_11 + subq_18.metric_time__day + ) subq_19 +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index ae64ce456a..c4a9c3e2bb 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -9,33 +9,33 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day AS metric_time__day - , COUNT(DISTINCT subq_16.bookers) AS every_2_days_bookers_2_days_ago + subq_26.metric_time__day AS metric_time__day + , COUNT(DISTINCT subq_25.bookers) AS every_2_days_bookers_2_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_18 + FROM ***************************.mf_time_spine subq_27 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_17 + ) subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_15.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_24 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_15.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_24.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > subq_15.ds - MAKE_INTERVAL(days => 2) + DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_24.ds - MAKE_INTERVAL(days => 2) ) - ) subq_16 + ) subq_25 ON - subq_17.metric_time__day - MAKE_INTERVAL(days => 2) = subq_16.metric_time__day - WHERE subq_17.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' + subq_26.metric_time__day - MAKE_INTERVAL(days => 2) = subq_25.metric_time__day + WHERE subq_26.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' GROUP BY - subq_17.metric_time__day -) subq_23 + subq_26.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0.sql index ea8a884590..7d019a0866 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0.sql @@ -1,445 +1,445 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_16.metric_time__day + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) -) subq_10 + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0_optimized.sql index 23f7234c6e..1638560b4d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , MAX(subq_15.ref_bookings) AS ref_bookings - , MAX(subq_20.bookings) AS bookings + COALESCE(subq_24.metric_time__day, subq_29.metric_time__day) AS metric_time__day + , MAX(subq_24.ref_bookings) AS ref_bookings + , MAX(subq_29.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,11 +21,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 GROUP BY metric_time__day - ) subq_15 + ) subq_24 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,13 +39,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_15.metric_time__day = subq_20.metric_time__day + subq_24.metric_time__day = subq_29.metric_time__day GROUP BY - COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) -) subq_21 + COALESCE(subq_24.metric_time__day, subq_29.metric_time__day) +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 95226e4eb9..f8dc6c39e5 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -1,73 +1,73 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__month + subq_9.metric_time__month , bookings_last_month AS bookings_last_month FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly AS bookings_last_month + subq_8.metric_time__month + , subq_8.bookings_monthly AS bookings_last_month FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__month - , SUM(subq_5.bookings_monthly) AS bookings_monthly + subq_7.metric_time__month + , SUM(subq_7.bookings_monthly) AS bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_4.metric_time__month - , subq_4.bookings_monthly + subq_6.metric_time__month + , subq_6.bookings_monthly FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__month AS metric_time__month - , subq_1.monthly_ds__month AS monthly_ds__month - , subq_1.monthly_ds__quarter AS monthly_ds__quarter - , subq_1.monthly_ds__year AS monthly_ds__year - , subq_1.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_1.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_1.listing AS listing - , subq_1.booking__listing AS booking__listing - , subq_1.bookings_monthly AS bookings_monthly + subq_4.metric_time__month AS metric_time__month + , subq_3.monthly_ds__month AS monthly_ds__month + , subq_3.monthly_ds__quarter AS monthly_ds__quarter + , subq_3.monthly_ds__year AS monthly_ds__year + , subq_3.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_3.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_3.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_3.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_3.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_3.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_3.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_3.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_3.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_3.listing AS listing + , subq_3.booking__listing AS booking__listing + , subq_3.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_3.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_3 + DATE_TRUNC('month', subq_5.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_5 GROUP BY - DATE_TRUNC('month', subq_3.ds) - ) subq_2 + DATE_TRUNC('month', subq_5.ds) + ) subq_4 INNER JOIN ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_2.monthly_ds__month + , subq_2.monthly_ds__quarter + , subq_2.monthly_ds__year + , subq_2.monthly_ds__extract_year + , subq_2.monthly_ds__extract_quarter + , subq_2.monthly_ds__extract_month + , subq_2.booking__monthly_ds__month + , subq_2.booking__monthly_ds__quarter + , subq_2.booking__monthly_ds__year + , subq_2.booking__monthly_ds__extract_year + , subq_2.booking__monthly_ds__extract_quarter + , subq_2.booking__monthly_ds__extract_month + , subq_2.monthly_ds__month AS metric_time__month + , subq_2.monthly_ds__quarter AS metric_time__quarter + , subq_2.monthly_ds__year AS metric_time__year + , subq_2.monthly_ds__extract_year AS metric_time__extract_year + , subq_2.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_2.monthly_ds__extract_month AS metric_time__extract_month + , subq_2.listing + , subq_2.booking__listing + , subq_2.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -87,13 +87,13 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 + ) subq_2 + ) subq_3 ON - subq_2.metric_time__month - MAKE_INTERVAL(months => 1) = subq_1.metric_time__month - ) subq_4 - ) subq_5 + subq_4.metric_time__month - MAKE_INTERVAL(months => 1) = subq_3.metric_time__month + ) subq_6 + ) subq_7 GROUP BY - subq_5.metric_time__month - ) subq_6 -) subq_7 + subq_7.metric_time__month + ) subq_8 +) subq_9 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index 314a91a06c..ed8ea8634b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -8,20 +8,20 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month AS metric_time__month + subq_12.metric_time__month AS metric_time__month , SUM(bookings_monthly_source_src_16000.bookings_monthly) AS bookings_last_month FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_13 GROUP BY DATE_TRUNC('month', ds) - ) subq_10 + ) subq_12 INNER JOIN ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 ON - subq_10.metric_time__month - MAKE_INTERVAL(months => 1) = DATE_TRUNC('month', bookings_monthly_source_src_16000.ds) + subq_12.metric_time__month - MAKE_INTERVAL(months => 1) = DATE_TRUNC('month', bookings_monthly_source_src_16000.ds) GROUP BY - subq_10.metric_time__month -) subq_15 + subq_12.metric_time__month +) subq_17 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql index 7128b81a47..05bcafad18 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__day - ) subq_11 - ) subq_12 + subq_19.metric_time__day + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) -) subq_13 + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 5138fe8ae6..2061be23cf 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day + DATE_TRUNC('month', subq_31.ds) = subq_29.metric_time__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) -) subq_27 + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index a18f1a3e30..a8b56fb822 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -1,546 +1,546 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__week + subq_22.metric_time__week , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) AS metric_time__week - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__week, subq_21.metric_time__week) AS metric_time__week + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__week - , subq_3.bookings + subq_12.metric_time__week + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__week - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__week + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_1.metric_time__week - , subq_1.bookings + subq_10.metric_time__week + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__week - ) subq_3 - ) subq_4 + subq_11.metric_time__week + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__week - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__week + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__week - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__week + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_9.metric_time__week - , subq_9.bookings + subq_18.metric_time__week + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('week', subq_7.metric_time__day) AS metric_time__week - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('week', subq_16.metric_time__day) AS metric_time__week + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.metric_time__day) = subq_6.metric_time__day - WHERE DATE_TRUNC('week', subq_7.metric_time__day) = subq_7.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.metric_time__day) = subq_15.metric_time__day + WHERE DATE_TRUNC('week', subq_16.metric_time__day) = subq_16.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__week - ) subq_11 - ) subq_12 + subq_19.metric_time__week + ) subq_20 + ) subq_21 ON - subq_4.metric_time__week = subq_12.metric_time__week + subq_13.metric_time__week = subq_21.metric_time__week GROUP BY - COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) -) subq_13 + COALESCE(subq_13.metric_time__week, subq_21.metric_time__week) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index b9e4162413..65cf132abd 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) AS metric_time__week - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__week, subq_35.metric_time__week) AS metric_time__week + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,36 +21,36 @@ FROM ( SELECT DATE_TRUNC('week', ds) AS metric_time__week , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__week - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__week'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('week', subq_22.ds) AS metric_time__week - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC('week', subq_31.ds) AS metric_time__week + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day - WHERE DATE_TRUNC('week', subq_22.ds) = subq_22.ds + DATE_TRUNC('month', subq_31.ds) = subq_29.metric_time__day + WHERE DATE_TRUNC('week', subq_31.ds) = subq_31.ds GROUP BY - DATE_TRUNC('week', subq_22.ds) - ) subq_26 + DATE_TRUNC('week', subq_31.ds) + ) subq_35 ON - subq_18.metric_time__week = subq_26.metric_time__week + subq_27.metric_time__week = subq_35.metric_time__week GROUP BY - COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) -) subq_27 + COALESCE(subq_27.metric_time__week, subq_35.metric_time__week) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql index ba751be035..7c51255420 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - subq_7.metric_time__day - MAKE_INTERVAL(days => 14) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + subq_16.metric_time__day - MAKE_INTERVAL(days => 14) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__day - ) subq_11 - ) subq_12 + subq_19.metric_time__day + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) -) subq_13 + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql index c71c75b485..304d0d012a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - subq_22.ds - MAKE_INTERVAL(days => 14) = subq_20.metric_time__day + subq_31.ds - MAKE_INTERVAL(days => 14) = subq_29.metric_time__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) -) subq_27 + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql index ec4e767aca..25d1a70740 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__quarter + subq_22.metric_time__quarter , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) AS metric_time__quarter - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__quarter, subq_21.metric_time__quarter) AS metric_time__quarter + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__quarter - , subq_3.bookings + subq_12.metric_time__quarter + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__quarter - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__quarter + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_1.metric_time__quarter - , subq_1.bookings + subq_10.metric_time__quarter + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__quarter - ) subq_3 - ) subq_4 + subq_11.metric_time__quarter + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__quarter - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__quarter + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__quarter - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__quarter + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_9.metric_time__quarter - , subq_9.bookings + subq_18.metric_time__quarter + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('quarter', subq_7.metric_time__day) AS metric_time__quarter - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('quarter', subq_16.metric_time__day) AS metric_time__quarter + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - subq_7.metric_time__day - MAKE_INTERVAL(days => 14) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + subq_16.metric_time__day - MAKE_INTERVAL(days => 14) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__quarter - ) subq_11 - ) subq_12 + subq_19.metric_time__quarter + ) subq_20 + ) subq_21 ON - subq_4.metric_time__quarter = subq_12.metric_time__quarter + subq_13.metric_time__quarter = subq_21.metric_time__quarter GROUP BY - COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) -) subq_13 + COALESCE(subq_13.metric_time__quarter, subq_21.metric_time__quarter) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index 4e2759b5d9..6567183a12 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) AS metric_time__quarter - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__quarter, subq_35.metric_time__quarter) AS metric_time__quarter + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('quarter', ds) AS metric_time__quarter , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__quarter - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__quarter'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('quarter', subq_22.ds) AS metric_time__quarter - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC('quarter', subq_31.ds) AS metric_time__quarter + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - subq_22.ds - MAKE_INTERVAL(days => 14) = subq_20.metric_time__day + subq_31.ds - MAKE_INTERVAL(days => 14) = subq_29.metric_time__day GROUP BY - DATE_TRUNC('quarter', subq_22.ds) - ) subq_26 + DATE_TRUNC('quarter', subq_31.ds) + ) subq_35 ON - subq_18.metric_time__quarter = subq_26.metric_time__quarter + subq_27.metric_time__quarter = subq_35.metric_time__quarter GROUP BY - COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) -) subq_27 + COALESCE(subq_27.metric_time__quarter, subq_35.metric_time__quarter) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 296c677724..410d334758 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -1,645 +1,645 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__day + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC('month', subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 + subq_14.metric_time__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - subq_10.metric_time__day - MAKE_INTERVAL(months => 1) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + subq_19.metric_time__day - MAKE_INTERVAL(months => 1) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__day - ) subq_14 - ) subq_15 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) -) subq_16 + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 0ec2c2c404..28c1c682f6 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -5,55 +5,55 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_20.ds AS metric_time__day - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + subq_29.ds AS metric_time__day + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day + DATE_TRUNC('month', subq_29.ds) = subq_27.metric_time__day GROUP BY - subq_20.ds - ) subq_24 + subq_29.ds + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - subq_28.ds - MAKE_INTERVAL(months => 1) = subq_26.metric_time__day + subq_37.ds - MAKE_INTERVAL(months => 1) = subq_35.metric_time__day GROUP BY - subq_28.ds - ) subq_32 + subq_37.ds + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index f4c09e0f1c..de3508c301 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -1,646 +1,646 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__year + subq_25.metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) AS metric_time__year - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__year, subq_24.metric_time__year) AS metric_time__year + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__year - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__year + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__year - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__year + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_4.metric_time__year - , subq_4.bookings + subq_13.metric_time__year + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('year', subq_11.metric_time__day) AS metric_time__year + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - WHERE DATE_TRUNC('year', subq_2.metric_time__day) = subq_2.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC('month', subq_11.metric_time__day) = subq_10.metric_time__day + WHERE DATE_TRUNC('year', subq_11.metric_time__day) = subq_11.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__year - ) subq_6 - ) subq_7 + subq_14.metric_time__year + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__year - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__year + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__year - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__year + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_12.metric_time__year - , subq_12.bookings + subq_21.metric_time__year + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_10.metric_time__day) AS metric_time__year - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('year', subq_19.metric_time__day) AS metric_time__year + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - subq_10.metric_time__day - MAKE_INTERVAL(months => 1) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + subq_19.metric_time__day - MAKE_INTERVAL(months => 1) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__year - ) subq_14 - ) subq_15 + subq_22.metric_time__year + ) subq_23 + ) subq_24 ON - subq_7.metric_time__year = subq_15.metric_time__year + subq_16.metric_time__year = subq_24.metric_time__year GROUP BY - COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) -) subq_16 + COALESCE(subq_16.metric_time__year, subq_24.metric_time__year) +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 3835603ac1..09bdaaf5da 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,56 +5,56 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) AS metric_time__year - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__year, subq_41.metric_time__year) AS metric_time__year + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_20.ds) AS metric_time__year - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + DATE_TRUNC('year', subq_29.ds) AS metric_time__year + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day - WHERE DATE_TRUNC('year', subq_20.ds) = subq_20.ds + DATE_TRUNC('month', subq_29.ds) = subq_27.metric_time__day + WHERE DATE_TRUNC('year', subq_29.ds) = subq_29.ds GROUP BY - DATE_TRUNC('year', subq_20.ds) - ) subq_24 + DATE_TRUNC('year', subq_29.ds) + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_28.ds) AS metric_time__year - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + DATE_TRUNC('year', subq_37.ds) AS metric_time__year + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - subq_28.ds - MAKE_INTERVAL(months => 1) = subq_26.metric_time__day + subq_37.ds - MAKE_INTERVAL(months => 1) = subq_35.metric_time__day GROUP BY - DATE_TRUNC('year', subq_28.ds) - ) subq_32 + DATE_TRUNC('year', subq_37.ds) + ) subq_41 ON - subq_24.metric_time__year = subq_32.metric_time__year + subq_33.metric_time__year = subq_41.metric_time__year GROUP BY - COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) -) subq_33 + COALESCE(subq_33.metric_time__year, subq_41.metric_time__year) +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index ca417f07cf..07633ee407 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_5.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_5.bookings) AS bookings - , MAX(subq_14.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_14.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_14.bookings) AS bookings + , MAX(subq_23.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_3.metric_time__day - , SUM(subq_3.bookings) AS bookings + subq_12.metric_time__day + , SUM(subq_12.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.bookings + subq_11.metric_time__day + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_3 + ) subq_12 GROUP BY - subq_3.metric_time__day - ) subq_4 - ) subq_5 + subq_12.metric_time__day + ) subq_13 + ) subq_14 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.bookings AS bookings_2_weeks_ago + subq_22.metric_time__day + , subq_22.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.bookings) AS bookings + subq_21.metric_time__day + , SUM(subq_21.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings + subq_20.metric_time__day + , subq_20.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_19.metric_time__day + , subq_19.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.ds__day AS ds__day - , subq_7.ds__week AS ds__week - , subq_7.ds__month AS ds__month - , subq_7.ds__quarter AS ds__quarter - , subq_7.ds__year AS ds__year - , subq_7.ds__extract_year AS ds__extract_year - , subq_7.ds__extract_quarter AS ds__extract_quarter - , subq_7.ds__extract_month AS ds__extract_month - , subq_7.ds__extract_day AS ds__extract_day - , subq_7.ds__extract_dow AS ds__extract_dow - , subq_7.ds__extract_doy AS ds__extract_doy - , subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__week AS ds_partitioned__week - , subq_7.ds_partitioned__month AS ds_partitioned__month - , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_7.ds_partitioned__year AS ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_7.paid_at__day AS paid_at__day - , subq_7.paid_at__week AS paid_at__week - , subq_7.paid_at__month AS paid_at__month - , subq_7.paid_at__quarter AS paid_at__quarter - , subq_7.paid_at__year AS paid_at__year - , subq_7.paid_at__extract_year AS paid_at__extract_year - , subq_7.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_7.paid_at__extract_month AS paid_at__extract_month - , subq_7.paid_at__extract_day AS paid_at__extract_day - , subq_7.paid_at__extract_dow AS paid_at__extract_dow - , subq_7.paid_at__extract_doy AS paid_at__extract_doy - , subq_7.booking__ds__day AS booking__ds__day - , subq_7.booking__ds__week AS booking__ds__week - , subq_7.booking__ds__month AS booking__ds__month - , subq_7.booking__ds__quarter AS booking__ds__quarter - , subq_7.booking__ds__year AS booking__ds__year - , subq_7.booking__ds__extract_year AS booking__ds__extract_year - , subq_7.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_7.booking__ds__extract_month AS booking__ds__extract_month - , subq_7.booking__ds__extract_day AS booking__ds__extract_day - , subq_7.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_7.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day AS booking__paid_at__day - , subq_7.booking__paid_at__week AS booking__paid_at__week - , subq_7.booking__paid_at__month AS booking__paid_at__month - , subq_7.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_7.booking__paid_at__year AS booking__paid_at__year - , subq_7.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_7.listing AS listing - , subq_7.guest AS guest - , subq_7.host AS host - , subq_7.booking__listing AS booking__listing - , subq_7.booking__guest AS booking__guest - , subq_7.booking__host AS booking__host - , subq_7.is_instant AS is_instant - , subq_7.booking__is_instant AS booking__is_instant - , subq_7.bookings AS bookings - , subq_7.instant_bookings AS instant_bookings - , subq_7.booking_value AS booking_value - , subq_7.max_booking_value AS max_booking_value - , subq_7.min_booking_value AS min_booking_value - , subq_7.bookers AS bookers - , subq_7.average_booking_value AS average_booking_value - , subq_7.referred_bookings AS referred_bookings - , subq_7.median_booking_value AS median_booking_value - , subq_7.booking_value_p99 AS booking_value_p99 - , subq_7.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_17.metric_time__day AS metric_time__day + , subq_16.ds__day AS ds__day + , subq_16.ds__week AS ds__week + , subq_16.ds__month AS ds__month + , subq_16.ds__quarter AS ds__quarter + , subq_16.ds__year AS ds__year + , subq_16.ds__extract_year AS ds__extract_year + , subq_16.ds__extract_quarter AS ds__extract_quarter + , subq_16.ds__extract_month AS ds__extract_month + , subq_16.ds__extract_day AS ds__extract_day + , subq_16.ds__extract_dow AS ds__extract_dow + , subq_16.ds__extract_doy AS ds__extract_doy + , subq_16.ds_partitioned__day AS ds_partitioned__day + , subq_16.ds_partitioned__week AS ds_partitioned__week + , subq_16.ds_partitioned__month AS ds_partitioned__month + , subq_16.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_16.ds_partitioned__year AS ds_partitioned__year + , subq_16.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_16.paid_at__day AS paid_at__day + , subq_16.paid_at__week AS paid_at__week + , subq_16.paid_at__month AS paid_at__month + , subq_16.paid_at__quarter AS paid_at__quarter + , subq_16.paid_at__year AS paid_at__year + , subq_16.paid_at__extract_year AS paid_at__extract_year + , subq_16.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_16.paid_at__extract_month AS paid_at__extract_month + , subq_16.paid_at__extract_day AS paid_at__extract_day + , subq_16.paid_at__extract_dow AS paid_at__extract_dow + , subq_16.paid_at__extract_doy AS paid_at__extract_doy + , subq_16.booking__ds__day AS booking__ds__day + , subq_16.booking__ds__week AS booking__ds__week + , subq_16.booking__ds__month AS booking__ds__month + , subq_16.booking__ds__quarter AS booking__ds__quarter + , subq_16.booking__ds__year AS booking__ds__year + , subq_16.booking__ds__extract_year AS booking__ds__extract_year + , subq_16.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_16.booking__ds__extract_month AS booking__ds__extract_month + , subq_16.booking__ds__extract_day AS booking__ds__extract_day + , subq_16.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_16.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day AS booking__paid_at__day + , subq_16.booking__paid_at__week AS booking__paid_at__week + , subq_16.booking__paid_at__month AS booking__paid_at__month + , subq_16.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_16.booking__paid_at__year AS booking__paid_at__year + , subq_16.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_16.listing AS listing + , subq_16.guest AS guest + , subq_16.host AS host + , subq_16.booking__listing AS booking__listing + , subq_16.booking__guest AS booking__guest + , subq_16.booking__host AS booking__host + , subq_16.is_instant AS is_instant + , subq_16.booking__is_instant AS booking__is_instant + , subq_16.bookings AS bookings + , subq_16.instant_bookings AS instant_bookings + , subq_16.booking_value AS booking_value + , subq_16.max_booking_value AS max_booking_value + , subq_16.min_booking_value AS min_booking_value + , subq_16.bookers AS bookers + , subq_16.average_booking_value AS average_booking_value + , subq_16.referred_bookings AS referred_bookings + , subq_16.median_booking_value AS median_booking_value + , subq_16.booking_value_p99 AS booking_value_p99 + , subq_16.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_16.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - ) subq_8 + subq_18.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + ) subq_17 INNER JOIN ( -- 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_15.ds__day + , subq_15.ds__week + , subq_15.ds__month + , subq_15.ds__quarter + , subq_15.ds__year + , subq_15.ds__extract_year + , subq_15.ds__extract_quarter + , subq_15.ds__extract_month + , subq_15.ds__extract_day + , subq_15.ds__extract_dow + , subq_15.ds__extract_doy + , subq_15.ds_partitioned__day + , subq_15.ds_partitioned__week + , subq_15.ds_partitioned__month + , subq_15.ds_partitioned__quarter + , subq_15.ds_partitioned__year + , subq_15.ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy + , subq_15.paid_at__day + , subq_15.paid_at__week + , subq_15.paid_at__month + , subq_15.paid_at__quarter + , subq_15.paid_at__year + , subq_15.paid_at__extract_year + , subq_15.paid_at__extract_quarter + , subq_15.paid_at__extract_month + , subq_15.paid_at__extract_day + , subq_15.paid_at__extract_dow + , subq_15.paid_at__extract_doy + , subq_15.booking__ds__day + , subq_15.booking__ds__week + , subq_15.booking__ds__month + , subq_15.booking__ds__quarter + , subq_15.booking__ds__year + , subq_15.booking__ds__extract_year + , subq_15.booking__ds__extract_quarter + , subq_15.booking__ds__extract_month + , subq_15.booking__ds__extract_day + , subq_15.booking__ds__extract_dow + , subq_15.booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day + , subq_15.booking__paid_at__week + , subq_15.booking__paid_at__month + , subq_15.booking__paid_at__quarter + , subq_15.booking__paid_at__year + , subq_15.booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy + , subq_15.ds__day AS metric_time__day + , subq_15.ds__week AS metric_time__week + , subq_15.ds__month AS metric_time__month + , subq_15.ds__quarter AS metric_time__quarter + , subq_15.ds__year AS metric_time__year + , subq_15.ds__extract_year AS metric_time__extract_year + , subq_15.ds__extract_quarter AS metric_time__extract_quarter + , subq_15.ds__extract_month AS metric_time__extract_month + , subq_15.ds__extract_day AS metric_time__extract_day + , subq_15.ds__extract_dow AS metric_time__extract_dow + , subq_15.ds__extract_doy AS metric_time__extract_doy + , subq_15.listing + , subq_15.guest + , subq_15.host + , subq_15.booking__listing + , subq_15.booking__guest + , subq_15.booking__host + , subq_15.is_instant + , subq_15.booking__is_instant + , subq_15.bookings + , subq_15.instant_bookings + , subq_15.booking_value + , subq_15.max_booking_value + , subq_15.min_booking_value + , subq_15.bookers + , subq_15.average_booking_value + , subq_15.referred_bookings + , subq_15.median_booking_value + , subq_15.booking_value_p99 + , subq_15.discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 + , subq_15.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 - ) subq_7 + , 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_15 + ) subq_16 ON - subq_8.metric_time__day - MAKE_INTERVAL(days => 14) = subq_7.metric_time__day - ) subq_10 - ) subq_11 + subq_17.metric_time__day - MAKE_INTERVAL(days => 14) = subq_16.metric_time__day + ) subq_19 + ) subq_20 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_12 + ) subq_21 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_21.metric_time__day + ) subq_22 + ) subq_23 ON - subq_5.metric_time__day = subq_14.metric_time__day + subq_14.metric_time__day = subq_23.metric_time__day GROUP BY - COALESCE(subq_5.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_14.metric_time__day, subq_23.metric_time__day) +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index a43927c170..536d9a95df 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_21.bookings) AS bookings - , MAX(subq_30.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_30.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_30.bookings) AS bookings + , MAX(subq_39.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -22,12 +22,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_21 + ) subq_30 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -39,26 +39,26 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_25.ds AS metric_time__day - , subq_23.bookings AS bookings - FROM ***************************.mf_time_spine subq_25 + subq_34.ds AS metric_time__day + , subq_32.bookings AS bookings + FROM ***************************.mf_time_spine subq_34 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 ON - subq_25.ds - MAKE_INTERVAL(days => 14) = subq_23.metric_time__day - ) subq_27 + subq_34.ds - MAKE_INTERVAL(days => 14) = subq_32.metric_time__day + ) subq_36 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_30 + ) subq_39 ON - subq_21.metric_time__day = subq_30.metric_time__day + subq_30.metric_time__day = subq_39.metric_time__day GROUP BY - COALESCE(subq_21.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_30.metric_time__day, subq_39.metric_time__day) +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql index 9f6aaa19c3..3d37c8406d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql @@ -1,433 +1,433 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookers AS every_2_days_bookers_2_days_ago + subq_18.metric_time__day + , subq_18.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , COUNT(DISTINCT subq_8.bookers) AS bookers + subq_17.metric_time__day + , COUNT(DISTINCT subq_17.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > subq_2.metric_time__day - MAKE_INTERVAL(days => 2) + subq_10.metric_time__day > subq_11.metric_time__day - MAKE_INTERVAL(days => 2) ) - ) subq_4 + ) subq_13 ON - subq_5.metric_time__day - MAKE_INTERVAL(days => 2) = subq_4.metric_time__day - ) subq_7 - ) subq_8 + subq_14.metric_time__day - MAKE_INTERVAL(days => 2) = subq_13.metric_time__day + ) subq_16 + ) subq_17 GROUP BY - subq_8.metric_time__day - ) subq_9 -) subq_10 + subq_17.metric_time__day + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0_optimized.sql index d021503497..fa1700be10 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -8,26 +8,26 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , COUNT(DISTINCT subq_15.bookers) AS every_2_days_bookers_2_days_ago - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , COUNT(DISTINCT subq_24.bookers) AS every_2_days_bookers_2_days_ago + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_14.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_14 + subq_23.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_23 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_23.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > subq_14.ds - MAKE_INTERVAL(days => 2) + DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_23.ds - MAKE_INTERVAL(days => 2) ) - ) subq_15 + ) subq_24 ON - subq_17.ds - MAKE_INTERVAL(days => 2) = subq_15.metric_time__day + subq_26.ds - MAKE_INTERVAL(days => 2) = subq_24.metric_time__day GROUP BY - subq_17.ds -) subq_21 + subq_26.ds +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0.sql index 270ee8720a..61d458d0a0 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_7.booking_value) AS booking_value - , MAX(subq_12.bookers) AS bookers + COALESCE(subq_16.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_16.booking_value) AS booking_value + , MAX(subq_21.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_6.booking__ds__day - , subq_6.booking_value + subq_15.booking__ds__day + , subq_15.booking_value FROM ( -- Aggregate Measures SELECT - subq_5.booking__ds__day - , SUM(subq_5.booking_value) AS booking_value + subq_14.booking__ds__day + , SUM(subq_14.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__ds__day'] SELECT - subq_4.booking__ds__day - , subq_4.booking_value + subq_13.booking__ds__day + , subq_13.booking_value FROM ( -- Join to Time Spine Dataset SELECT - subq_2.booking__ds__day AS booking__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.booking__ds__day AS booking__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.booking__ds__day - MAKE_INTERVAL(weeks => 1) = subq_1.booking__ds__day - ) subq_4 - ) subq_5 + subq_11.booking__ds__day - MAKE_INTERVAL(weeks => 1) = subq_10.booking__ds__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.booking__ds__day - ) subq_6 - ) subq_7 + subq_14.booking__ds__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookers + subq_20.booking__ds__day + , subq_20.bookers FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , COUNT(DISTINCT subq_10.bookers) AS bookers + subq_19.booking__ds__day + , COUNT(DISTINCT subq_19.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookers + subq_18.booking__ds__day + , subq_18.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 - ) subq_10 + , 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_17 + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_7.booking__ds__day = subq_12.booking__ds__day + subq_16.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_7.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_16.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql index bb2d834047..0ea88766b0 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql @@ -5,25 +5,25 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_21.booking_value) AS booking_value - , MAX(subq_26.bookers) AS bookers + COALESCE(subq_30.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_30.booking_value) AS booking_value + , MAX(subq_35.bookers) AS bookers FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['booking_value', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS booking__ds__day - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS booking__ds__day + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.mf_time_spine subq_26 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON - subq_17.ds - MAKE_INTERVAL(weeks => 1) = DATE_TRUNC('day', bookings_source_src_28001.ds) + subq_26.ds - MAKE_INTERVAL(weeks => 1) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds - ) subq_21 + subq_26.ds + ) subq_30 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -33,12 +33,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , COUNT(DISTINCT guest_id) AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_26 + ) subq_35 ON - subq_21.booking__ds__day = subq_26.booking__ds__day + subq_30.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_21.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_30.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql index 38816518fd..42f80363f5 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -1,319 +1,319 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.metric_time__day - MAKE_INTERVAL(days => 5) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + subq_11.metric_time__day - MAKE_INTERVAL(days => 5) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 -) subq_7 + subq_14.metric_time__day + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 0b538a304a..7b052383df 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -8,19 +8,19 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago + FROM ***************************.mf_time_spine subq_20 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - subq_11.ds - MAKE_INTERVAL(days => 5) = subq_9.metric_time__day + subq_20.ds - MAKE_INTERVAL(days => 5) = subq_18.metric_time__day GROUP BY - subq_11.ds -) subq_15 + subq_20.ds +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0.sql index 2d28d5feb7..7918ef7e73 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0.sql @@ -1,895 +1,895 @@ -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day + subq_31.metric_time__day , non_referred + (instant * 1.0 / bookings) AS instant_plus_non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) AS metric_time__day - , MAX(subq_11.non_referred) AS non_referred - , MAX(subq_16.instant) AS instant - , MAX(subq_21.bookings) AS bookings + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day + , MAX(subq_20.non_referred) AS non_referred + , MAX(subq_25.instant) AS instant + , MAX(subq_30.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_16.metric_time__day + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) - ) subq_10 - ) subq_11 + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day - , subq_15.instant_bookings AS instant + subq_24.metric_time__day + , subq_24.instant_bookings AS instant FROM ( -- Aggregate Measures SELECT - subq_14.metric_time__day - , SUM(subq_14.instant_bookings) AS instant_bookings + subq_23.metric_time__day + , SUM(subq_23.instant_bookings) AS instant_bookings FROM ( -- Pass Only Elements: ['instant_bookings', 'metric_time__day'] SELECT - subq_13.metric_time__day - , subq_13.instant_bookings + subq_22.metric_time__day + , subq_22.instant_bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 GROUP BY - subq_14.metric_time__day - ) subq_15 - ) subq_16 + subq_23.metric_time__day + ) subq_24 + ) subq_25 ON - subq_11.metric_time__day = subq_16.metric_time__day + subq_20.metric_time__day = subq_25.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Aggregate Measures SELECT - subq_19.metric_time__day - , SUM(subq_19.bookings) AS bookings + subq_28.metric_time__day + , SUM(subq_28.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.bookings + subq_27.metric_time__day + , subq_27.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_17.ds__day - , subq_17.ds__week - , subq_17.ds__month - , subq_17.ds__quarter - , subq_17.ds__year - , subq_17.ds__extract_year - , subq_17.ds__extract_quarter - , subq_17.ds__extract_month - , subq_17.ds__extract_day - , subq_17.ds__extract_dow - , subq_17.ds__extract_doy - , subq_17.ds_partitioned__day - , subq_17.ds_partitioned__week - , subq_17.ds_partitioned__month - , subq_17.ds_partitioned__quarter - , subq_17.ds_partitioned__year - , subq_17.ds_partitioned__extract_year - , subq_17.ds_partitioned__extract_quarter - , subq_17.ds_partitioned__extract_month - , subq_17.ds_partitioned__extract_day - , subq_17.ds_partitioned__extract_dow - , subq_17.ds_partitioned__extract_doy - , subq_17.paid_at__day - , subq_17.paid_at__week - , subq_17.paid_at__month - , subq_17.paid_at__quarter - , subq_17.paid_at__year - , subq_17.paid_at__extract_year - , subq_17.paid_at__extract_quarter - , subq_17.paid_at__extract_month - , subq_17.paid_at__extract_day - , subq_17.paid_at__extract_dow - , subq_17.paid_at__extract_doy - , subq_17.booking__ds__day - , subq_17.booking__ds__week - , subq_17.booking__ds__month - , subq_17.booking__ds__quarter - , subq_17.booking__ds__year - , subq_17.booking__ds__extract_year - , subq_17.booking__ds__extract_quarter - , subq_17.booking__ds__extract_month - , subq_17.booking__ds__extract_day - , subq_17.booking__ds__extract_dow - , subq_17.booking__ds__extract_doy - , subq_17.booking__ds_partitioned__day - , subq_17.booking__ds_partitioned__week - , subq_17.booking__ds_partitioned__month - , subq_17.booking__ds_partitioned__quarter - , subq_17.booking__ds_partitioned__year - , subq_17.booking__ds_partitioned__extract_year - , subq_17.booking__ds_partitioned__extract_quarter - , subq_17.booking__ds_partitioned__extract_month - , subq_17.booking__ds_partitioned__extract_day - , subq_17.booking__ds_partitioned__extract_dow - , subq_17.booking__ds_partitioned__extract_doy - , subq_17.booking__paid_at__day - , subq_17.booking__paid_at__week - , subq_17.booking__paid_at__month - , subq_17.booking__paid_at__quarter - , subq_17.booking__paid_at__year - , subq_17.booking__paid_at__extract_year - , subq_17.booking__paid_at__extract_quarter - , subq_17.booking__paid_at__extract_month - , subq_17.booking__paid_at__extract_day - , subq_17.booking__paid_at__extract_dow - , subq_17.booking__paid_at__extract_doy - , subq_17.ds__day AS metric_time__day - , subq_17.ds__week AS metric_time__week - , subq_17.ds__month AS metric_time__month - , subq_17.ds__quarter AS metric_time__quarter - , subq_17.ds__year AS metric_time__year - , subq_17.ds__extract_year AS metric_time__extract_year - , subq_17.ds__extract_quarter AS metric_time__extract_quarter - , subq_17.ds__extract_month AS metric_time__extract_month - , subq_17.ds__extract_day AS metric_time__extract_day - , subq_17.ds__extract_dow AS metric_time__extract_dow - , subq_17.ds__extract_doy AS metric_time__extract_doy - , subq_17.listing - , subq_17.guest - , subq_17.host - , subq_17.booking__listing - , subq_17.booking__guest - , subq_17.booking__host - , subq_17.is_instant - , subq_17.booking__is_instant - , subq_17.bookings - , subq_17.instant_bookings - , subq_17.booking_value - , subq_17.max_booking_value - , subq_17.min_booking_value - , subq_17.bookers - , subq_17.average_booking_value - , subq_17.referred_bookings - , subq_17.median_booking_value - , subq_17.booking_value_p99 - , subq_17.discrete_booking_value_p99 - , subq_17.approximate_continuous_booking_value_p99 - , subq_17.approximate_discrete_booking_value_p99 + subq_26.ds__day + , subq_26.ds__week + , subq_26.ds__month + , subq_26.ds__quarter + , subq_26.ds__year + , subq_26.ds__extract_year + , subq_26.ds__extract_quarter + , subq_26.ds__extract_month + , subq_26.ds__extract_day + , subq_26.ds__extract_dow + , subq_26.ds__extract_doy + , subq_26.ds_partitioned__day + , subq_26.ds_partitioned__week + , subq_26.ds_partitioned__month + , subq_26.ds_partitioned__quarter + , subq_26.ds_partitioned__year + , subq_26.ds_partitioned__extract_year + , subq_26.ds_partitioned__extract_quarter + , subq_26.ds_partitioned__extract_month + , subq_26.ds_partitioned__extract_day + , subq_26.ds_partitioned__extract_dow + , subq_26.ds_partitioned__extract_doy + , subq_26.paid_at__day + , subq_26.paid_at__week + , subq_26.paid_at__month + , subq_26.paid_at__quarter + , subq_26.paid_at__year + , subq_26.paid_at__extract_year + , subq_26.paid_at__extract_quarter + , subq_26.paid_at__extract_month + , subq_26.paid_at__extract_day + , subq_26.paid_at__extract_dow + , subq_26.paid_at__extract_doy + , subq_26.booking__ds__day + , subq_26.booking__ds__week + , subq_26.booking__ds__month + , subq_26.booking__ds__quarter + , subq_26.booking__ds__year + , subq_26.booking__ds__extract_year + , subq_26.booking__ds__extract_quarter + , subq_26.booking__ds__extract_month + , subq_26.booking__ds__extract_day + , subq_26.booking__ds__extract_dow + , subq_26.booking__ds__extract_doy + , subq_26.booking__ds_partitioned__day + , subq_26.booking__ds_partitioned__week + , subq_26.booking__ds_partitioned__month + , subq_26.booking__ds_partitioned__quarter + , subq_26.booking__ds_partitioned__year + , subq_26.booking__ds_partitioned__extract_year + , subq_26.booking__ds_partitioned__extract_quarter + , subq_26.booking__ds_partitioned__extract_month + , subq_26.booking__ds_partitioned__extract_day + , subq_26.booking__ds_partitioned__extract_dow + , subq_26.booking__ds_partitioned__extract_doy + , subq_26.booking__paid_at__day + , subq_26.booking__paid_at__week + , subq_26.booking__paid_at__month + , subq_26.booking__paid_at__quarter + , subq_26.booking__paid_at__year + , subq_26.booking__paid_at__extract_year + , subq_26.booking__paid_at__extract_quarter + , subq_26.booking__paid_at__extract_month + , subq_26.booking__paid_at__extract_day + , subq_26.booking__paid_at__extract_dow + , subq_26.booking__paid_at__extract_doy + , subq_26.ds__day AS metric_time__day + , subq_26.ds__week AS metric_time__week + , subq_26.ds__month AS metric_time__month + , subq_26.ds__quarter AS metric_time__quarter + , subq_26.ds__year AS metric_time__year + , subq_26.ds__extract_year AS metric_time__extract_year + , subq_26.ds__extract_quarter AS metric_time__extract_quarter + , subq_26.ds__extract_month AS metric_time__extract_month + , subq_26.ds__extract_day AS metric_time__extract_day + , subq_26.ds__extract_dow AS metric_time__extract_dow + , subq_26.ds__extract_doy AS metric_time__extract_doy + , subq_26.listing + , subq_26.guest + , subq_26.host + , subq_26.booking__listing + , subq_26.booking__guest + , subq_26.booking__host + , subq_26.is_instant + , subq_26.booking__is_instant + , subq_26.bookings + , subq_26.instant_bookings + , subq_26.booking_value + , subq_26.max_booking_value + , subq_26.min_booking_value + , subq_26.bookers + , subq_26.average_booking_value + , subq_26.referred_bookings + , subq_26.median_booking_value + , subq_26.booking_value_p99 + , subq_26.discrete_booking_value_p99 + , subq_26.approximate_continuous_booking_value_p99 + , subq_26.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_17 - ) subq_18 - ) subq_19 + , 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_26 + ) subq_27 + ) subq_28 GROUP BY - subq_19.metric_time__day - ) subq_20 - ) subq_21 + subq_28.metric_time__day + ) subq_29 + ) subq_30 ON - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day) = subq_21.metric_time__day + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day) = subq_30.metric_time__day GROUP BY - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) -) subq_22 + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day, subq_30.metric_time__day) +) subq_31 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0_optimized.sql index 78837fdd96..da1e9fdd5a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) AS metric_time__day - , MAX(subq_34.non_referred) AS non_referred - , MAX(subq_39.instant) AS instant - , MAX(subq_44.bookings) AS bookings + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day, subq_53.metric_time__day) AS metric_time__day + , MAX(subq_43.non_referred) AS non_referred + , MAX(subq_48.instant) AS instant + , MAX(subq_53.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -17,9 +17,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.ref_bookings) AS ref_bookings - , MAX(subq_32.bookings) AS bookings + COALESCE(subq_36.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_36.ref_bookings) AS ref_bookings + , MAX(subq_41.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -33,11 +33,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_25 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_34 GROUP BY metric_time__day - ) subq_27 + ) subq_36 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -51,17 +51,17 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_30 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_39 GROUP BY metric_time__day - ) subq_32 + ) subq_41 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_36.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) - ) subq_33 - ) subq_34 + COALESCE(subq_36.metric_time__day, subq_41.metric_time__day) + ) subq_42 + ) subq_43 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -75,13 +75,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_37 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_46 GROUP BY metric_time__day - ) subq_39 + ) subq_48 ON - subq_34.metric_time__day = subq_39.metric_time__day + subq_43.metric_time__day = subq_48.metric_time__day FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -95,13 +95,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_42 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_51 GROUP BY metric_time__day - ) subq_44 + ) subq_53 ON - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day) = subq_44.metric_time__day + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day) = subq_53.metric_time__day GROUP BY - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) -) subq_45 + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day, subq_53.metric_time__day) +) subq_54 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 7f1880083e..d0d0820c64 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -1,359 +1,359 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Pass Only Elements: ['metric_time__day', 'bookings_offset_once'] SELECT - subq_12.metric_time__day - , subq_12.bookings_offset_once + subq_21.metric_time__day + , subq_21.bookings_offset_once FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.booking__is_instant - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.booking__is_instant + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.booking__is_instant AS booking__is_instant - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.booking__is_instant AS booking__is_instant + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant + subq_16.metric_time__day + , subq_16.booking__is_instant , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.bookings + subq_15.metric_time__day + , subq_15.booking__is_instant + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , subq_14.booking__is_instant + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_13.metric_time__day + , subq_13.booking__is_instant + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.metric_time__day - MAKE_INTERVAL(days => 5) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + subq_11.metric_time__day - MAKE_INTERVAL(days => 5) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - , subq_5.booking__is_instant - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + , subq_14.booking__is_instant + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_9.metric_time__day - MAKE_INTERVAL(days => 2) = subq_8.metric_time__day - ) subq_11 + subq_18.metric_time__day - MAKE_INTERVAL(days => 2) = subq_17.metric_time__day + ) subq_20 WHERE booking__is_instant - ) subq_12 -) subq_13 + ) subq_21 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index 9a38bf2182..95e045d876 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -11,10 +11,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_24.ds AS metric_time__day - , subq_22.booking__is_instant AS booking__is_instant - , subq_22.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_24 + subq_33.ds AS metric_time__day + , subq_31.booking__is_instant AS booking__is_instant + , subq_31.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_33 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -27,10 +27,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , subq_15.booking__is_instant AS booking__is_instant - , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , subq_24.booking__is_instant AS booking__is_instant + , SUM(subq_24.bookings) AS bookings + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -38,17 +38,17 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 ON - subq_17.ds - MAKE_INTERVAL(days => 5) = subq_15.metric_time__day + subq_26.ds - MAKE_INTERVAL(days => 5) = subq_24.metric_time__day GROUP BY - subq_17.ds - , subq_15.booking__is_instant - ) subq_21 - ) subq_22 + subq_26.ds + , subq_24.booking__is_instant + ) subq_30 + ) subq_31 ON - subq_24.ds - MAKE_INTERVAL(days => 2) = subq_22.metric_time__day - ) subq_25 + subq_33.ds - MAKE_INTERVAL(days => 2) = subq_31.metric_time__day + ) subq_34 WHERE booking__is_instant -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql index b6024d9277..36d9bb6cd4 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql @@ -1,471 +1,471 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , booking_fees - booking_fees_start_of_month AS booking_fees_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_8.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_8.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_14.booking_fees) AS booking_fees + COALESCE(subq_17.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_17.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_23.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.booking_fees_start_of_month AS booking_fees_start_of_month + subq_15.metric_time__day AS metric_time__day + , subq_14.booking_fees_start_of_month AS booking_fees_start_of_month FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_6 + subq_16.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + ) subq_15 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day + subq_13.metric_time__day , booking_value * 0.05 AS booking_fees_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.booking_value) AS booking_value + subq_11.metric_time__day + , SUM(subq_11.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 - ) subq_5 + subq_11.metric_time__day + ) subq_12 + ) subq_13 + ) subq_14 ON - DATE_TRUNC('month', subq_6.metric_time__day) = subq_5.metric_time__day - ) subq_8 + DATE_TRUNC('month', subq_15.metric_time__day) = subq_14.metric_time__day + ) subq_17 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , booking_value * 0.05 AS booking_fees FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value + subq_21.metric_time__day + , subq_21.booking_value FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_20.metric_time__day + , SUM(subq_20.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_19.metric_time__day + , subq_19.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__extract_quarter - , subq_9.ds__extract_month - , subq_9.ds__extract_day - , subq_9.ds__extract_dow - , subq_9.ds__extract_doy - , subq_9.ds_partitioned__day - , subq_9.ds_partitioned__week - , subq_9.ds_partitioned__month - , subq_9.ds_partitioned__quarter - , subq_9.ds_partitioned__year - , subq_9.ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy - , subq_9.paid_at__day - , subq_9.paid_at__week - , subq_9.paid_at__month - , subq_9.paid_at__quarter - , subq_9.paid_at__year - , subq_9.paid_at__extract_year - , subq_9.paid_at__extract_quarter - , subq_9.paid_at__extract_month - , subq_9.paid_at__extract_day - , subq_9.paid_at__extract_dow - , subq_9.paid_at__extract_doy - , subq_9.booking__ds__day - , subq_9.booking__ds__week - , subq_9.booking__ds__month - , subq_9.booking__ds__quarter - , subq_9.booking__ds__year - , subq_9.booking__ds__extract_year - , subq_9.booking__ds__extract_quarter - , subq_9.booking__ds__extract_month - , subq_9.booking__ds__extract_day - , subq_9.booking__ds__extract_dow - , subq_9.booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day - , subq_9.booking__paid_at__week - , subq_9.booking__paid_at__month - , subq_9.booking__paid_at__quarter - , subq_9.booking__paid_at__year - , subq_9.booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy - , subq_9.ds__day AS metric_time__day - , subq_9.ds__week AS metric_time__week - , subq_9.ds__month AS metric_time__month - , subq_9.ds__quarter AS metric_time__quarter - , subq_9.ds__year AS metric_time__year - , subq_9.ds__extract_year AS metric_time__extract_year - , subq_9.ds__extract_quarter AS metric_time__extract_quarter - , subq_9.ds__extract_month AS metric_time__extract_month - , subq_9.ds__extract_day AS metric_time__extract_day - , subq_9.ds__extract_dow AS metric_time__extract_dow - , subq_9.ds__extract_doy AS metric_time__extract_doy - , subq_9.listing - , subq_9.guest - , subq_9.host - , subq_9.booking__listing - , subq_9.booking__guest - , subq_9.booking__host - , subq_9.is_instant - , subq_9.booking__is_instant - , subq_9.bookings - , subq_9.instant_bookings - , subq_9.booking_value - , subq_9.max_booking_value - , subq_9.min_booking_value - , subq_9.bookers - , subq_9.average_booking_value - , subq_9.referred_bookings - , subq_9.median_booking_value - , subq_9.booking_value_p99 - , subq_9.discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 + 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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 - ) subq_10 - ) subq_11 + , 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_18 + ) subq_19 + ) subq_20 GROUP BY - subq_11.metric_time__day - ) subq_12 - ) subq_13 - ) subq_14 + subq_20.metric_time__day + ) subq_21 + ) subq_22 + ) subq_23 ON - subq_8.metric_time__day = subq_14.metric_time__day + subq_17.metric_time__day = subq_23.metric_time__day GROUP BY - COALESCE(subq_8.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_17.metric_time__day, subq_23.metric_time__day) +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql index fc648c54b6..b28105f311 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_24.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_30.booking_fees) AS booking_fees + COALESCE(subq_33.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_33.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_39.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.booking_fees_start_of_month AS booking_fees_start_of_month - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.booking_fees_start_of_month AS booking_fees_start_of_month + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,14 +28,14 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 ON - DATE_TRUNC('month', subq_23.ds) = subq_21.metric_time__day - ) subq_24 + DATE_TRUNC('month', subq_32.ds) = subq_30.metric_time__day + ) subq_33 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT @@ -50,13 +50,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_29 - ) subq_30 + ) subq_38 + ) subq_39 ON - subq_24.metric_time__day = subq_30.metric_time__day + subq_33.metric_time__day = subq_39.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_33.metric_time__day, subq_39.metric_time__day) +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0.sql index 25419e889e..dd594f7ee4 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0.sql @@ -8,991 +8,991 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_30.booking_value) AS booking_value + MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.average_booking_value + subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_9.average_booking_value) AS average_booking_value + AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_8.average_booking_value + subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.booking__is_instant + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.booking__is_instant + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value 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_2.average_booking_value AS average_booking_value + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.average_booking_value + subq_10.listing + , subq_10.booking__is_instant + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_8 - ) subq_9 - ) subq_10 - ) subq_11 + ) subq_17 + ) subq_18 + ) subq_19 + ) subq_20 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.bookings + subq_31.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_21.bookings) AS bookings + SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_20.bookings + subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.booking__is_instant - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.booking__is_instant + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_18.booking__is_instant - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.listing AS listing - , subq_14.booking__is_instant AS booking__is_instant - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.listing AS listing + , subq_23.booking__is_instant AS booking__is_instant + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_13.listing - , subq_13.booking__is_instant - , subq_13.bookings + subq_22.listing + , subq_22.booking__is_instant + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_20 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_29 + ) subq_30 + ) subq_31 + ) subq_32 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_29.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_28.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_27.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 -) subq_32 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0_optimized.sql index 14649c62dd..35859d3713 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0_optimized.sql +++ b/metricflow/test/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_44.average_booking_value) AS average_booking_value - , MAX(subq_56.bookings) AS bookings - , MAX(subq_63.booking_value) AS booking_value + MAX(subq_53.average_booking_value) AS average_booking_value + , MAX(subq_65.bookings) AS bookings + , MAX(subq_72.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,17 +22,17 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - bookings_source_src_28001.is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_40 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_49 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_44 + ) subq_53 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -44,9 +44,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_47.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_47.bookings AS bookings + subq_56.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_56.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -55,15 +55,15 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_47 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_56 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_47.listing = listings_latest_src_28005.listing_id - ) subq_52 + subq_56.listing = listings_latest_src_28000.listing_id + ) subq_61 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_56 + ) subq_65 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -78,9 +78,9 @@ FROM ( SELECT is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_59 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_68 WHERE booking__is_instant - ) subq_63 - ) subq_64 -) subq_65 + ) subq_72 + ) subq_73 +) subq_74 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0.sql index f76ae0aca9..49227536c3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0.sql @@ -1,339 +1,339 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.metric_time__day - MAKE_INTERVAL(days => 5) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + subq_11.metric_time__day - MAKE_INTERVAL(days => 5) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_9.metric_time__day - MAKE_INTERVAL(days => 2) = subq_8.metric_time__day -) subq_11 + subq_18.metric_time__day - MAKE_INTERVAL(days => 2) = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0_optimized.sql index dcf61d5017..dd486ba0ad 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -19,23 +19,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - subq_15.ds - MAKE_INTERVAL(days => 5) = subq_13.metric_time__day + subq_24.ds - MAKE_INTERVAL(days => 5) = subq_22.metric_time__day GROUP BY - subq_15.ds - ) subq_19 - ) subq_20 + subq_24.ds + ) subq_28 + ) subq_29 ON - subq_22.ds - MAKE_INTERVAL(days => 2) = subq_20.metric_time__day -) subq_23 + subq_31.ds - MAKE_INTERVAL(days => 2) = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0.sql index 41f0e1b70c..1787519f1d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0.sql @@ -1,340 +1,340 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - WHERE subq_10.ds BETWEEN '2020-01-12' AND '2020-01-13' - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + WHERE subq_19.ds BETWEEN '2020-01-12' AND '2020-01-13' + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.metric_time__day - MAKE_INTERVAL(days => 5) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + subq_11.metric_time__day - MAKE_INTERVAL(days => 5) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_9.metric_time__day - MAKE_INTERVAL(days => 2) = subq_8.metric_time__day -) subq_11 + subq_18.metric_time__day - MAKE_INTERVAL(days => 2) = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0_optimized.sql index e5b6f01b58..b0f023c10d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_21.metric_time__day AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once + subq_30.metric_time__day AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_22 + FROM ***************************.mf_time_spine subq_31 WHERE ds BETWEEN '2020-01-12' AND '2020-01-13' - ) subq_21 + ) subq_30 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -25,23 +25,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - subq_15.ds - MAKE_INTERVAL(days => 5) = subq_13.metric_time__day + subq_24.ds - MAKE_INTERVAL(days => 5) = subq_22.metric_time__day GROUP BY - subq_15.ds - ) subq_19 - ) subq_20 + subq_24.ds + ) subq_28 + ) subq_29 ON - subq_21.metric_time__day - MAKE_INTERVAL(days => 2) = subq_20.metric_time__day -) subq_23 + subq_30.metric_time__day - MAKE_INTERVAL(days => 2) = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0.sql index 3fa4be6986..6f4645d17b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0.sql @@ -1,346 +1,346 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day + subq_21.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.metric_time__day - MAKE_INTERVAL(days => 5) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + subq_11.metric_time__day - MAKE_INTERVAL(days => 5) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_9.metric_time__day - MAKE_INTERVAL(days => 2) = subq_8.metric_time__day - ) subq_11 + subq_18.metric_time__day - MAKE_INTERVAL(days => 2) = subq_17.metric_time__day + ) subq_20 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_12 +) subq_21 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0_optimized.sql index a6a237f85e..0a7d172195 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -10,9 +10,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,25 +24,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.ds AS metric_time__day - , SUM(subq_14.bookings) AS bookings - FROM ***************************.mf_time_spine subq_16 + subq_25.ds AS metric_time__day + , SUM(subq_23.bookings) AS bookings + FROM ***************************.mf_time_spine subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_14 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_23 ON - subq_16.ds - MAKE_INTERVAL(days => 5) = subq_14.metric_time__day + subq_25.ds - MAKE_INTERVAL(days => 5) = subq_23.metric_time__day GROUP BY - subq_16.ds - ) subq_20 - ) subq_21 + subq_25.ds + ) subq_29 + ) subq_30 ON - subq_23.ds - MAKE_INTERVAL(days => 2) = subq_21.metric_time__day - ) subq_24 + subq_32.ds - MAKE_INTERVAL(days => 2) = subq_30.metric_time__day + ) subq_33 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_25 +) subq_34 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0.sql index df42cd08d1..efe0218840 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__ds__day - ) subq_3 - ) subq_4 + subq_11.booking__ds__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.booking__ds__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.booking__ds__day) = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.booking__ds__day) = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql index 1b7dbc4725..9f6d4b5769 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.booking__ds__day + DATE_TRUNC('month', subq_31.ds) = subq_29.booking__ds__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0.sql index 906ccac318..588ee03af1 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__ds__day - ) subq_3 - ) subq_4 + subq_11.booking__ds__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.booking__ds__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - subq_7.booking__ds__day - MAKE_INTERVAL(days => 14) = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + subq_16.booking__ds__day - MAKE_INTERVAL(days => 14) = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0_optimized.sql index 3daea0d8e2..9230049ec8 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - subq_22.ds - MAKE_INTERVAL(days => 14) = subq_20.booking__ds__day + subq_31.ds - MAKE_INTERVAL(days => 14) = subq_29.booking__ds__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0.sql index 4e00e95c17..4c79f89e04 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0.sql @@ -1,320 +1,320 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - WHERE subq_3.ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + WHERE subq_12.ds BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - subq_2.metric_time__day - MAKE_INTERVAL(days => 5) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + subq_11.metric_time__day - MAKE_INTERVAL(days => 5) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 -) subq_7 + subq_14.metric_time__day + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0_optimized.sql index c29d0d741b..22f3ca9760 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -8,25 +8,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago + subq_19.metric_time__day AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_20 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_10 + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - subq_10.metric_time__day - MAKE_INTERVAL(days => 5) = subq_9.metric_time__day + subq_19.metric_time__day - MAKE_INTERVAL(days => 5) = subq_18.metric_time__day GROUP BY - subq_10.metric_time__day -) subq_15 + subq_19.metric_time__day +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 7f8a2e0812..d63b5acd64 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -1,441 +1,441 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.bookers AS every_2_days_bookers_2_days_ago + subq_19.metric_time__day + , subq_19.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , COUNT(DISTINCT subq_9.bookers) AS bookers + subq_18.metric_time__day + , COUNT(DISTINCT subq_18.bookers) AS bookers FROM ( -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] SELECT - subq_8.metric_time__day - , subq_8.bookers + subq_17.metric_time__day + , subq_17.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -2, subq_11.metric_time__day) ) - ) subq_4 + ) subq_13 ON - DATEADD(day, -2, subq_5.metric_time__day) = subq_4.metric_time__day - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_9 + DATEADD(day, -2, subq_14.metric_time__day) = subq_13.metric_time__day + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 -) subq_11 + subq_18.metric_time__day + ) subq_19 +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index d998382fb8..0f2d801995 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -9,33 +9,33 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day AS metric_time__day - , COUNT(DISTINCT subq_16.bookers) AS every_2_days_bookers_2_days_ago + subq_26.metric_time__day AS metric_time__day + , COUNT(DISTINCT subq_25.bookers) AS every_2_days_bookers_2_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_18 + FROM ***************************.mf_time_spine subq_27 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_17 + ) subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_15.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_24 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_15.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_24.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATEADD(day, -2, subq_15.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_24.ds) ) - ) subq_16 + ) subq_25 ON - DATEADD(day, -2, subq_17.metric_time__day) = subq_16.metric_time__day - WHERE subq_17.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' + DATEADD(day, -2, subq_26.metric_time__day) = subq_25.metric_time__day + WHERE subq_26.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' GROUP BY - subq_17.metric_time__day -) subq_23 + subq_26.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0.sql index 80cde693e4..787691532a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0.sql @@ -1,445 +1,445 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_16.metric_time__day + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) -) subq_10 + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0_optimized.sql index 23f7234c6e..1638560b4d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , MAX(subq_15.ref_bookings) AS ref_bookings - , MAX(subq_20.bookings) AS bookings + COALESCE(subq_24.metric_time__day, subq_29.metric_time__day) AS metric_time__day + , MAX(subq_24.ref_bookings) AS ref_bookings + , MAX(subq_29.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,11 +21,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 GROUP BY metric_time__day - ) subq_15 + ) subq_24 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,13 +39,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_15.metric_time__day = subq_20.metric_time__day + subq_24.metric_time__day = subq_29.metric_time__day GROUP BY - COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) -) subq_21 + COALESCE(subq_24.metric_time__day, subq_29.metric_time__day) +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 72735021e2..35be63856a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -1,73 +1,73 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__month + subq_9.metric_time__month , bookings_last_month AS bookings_last_month FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly AS bookings_last_month + subq_8.metric_time__month + , subq_8.bookings_monthly AS bookings_last_month FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__month - , SUM(subq_5.bookings_monthly) AS bookings_monthly + subq_7.metric_time__month + , SUM(subq_7.bookings_monthly) AS bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_4.metric_time__month - , subq_4.bookings_monthly + subq_6.metric_time__month + , subq_6.bookings_monthly FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__month AS metric_time__month - , subq_1.monthly_ds__month AS monthly_ds__month - , subq_1.monthly_ds__quarter AS monthly_ds__quarter - , subq_1.monthly_ds__year AS monthly_ds__year - , subq_1.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_1.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_1.listing AS listing - , subq_1.booking__listing AS booking__listing - , subq_1.bookings_monthly AS bookings_monthly + subq_4.metric_time__month AS metric_time__month + , subq_3.monthly_ds__month AS monthly_ds__month + , subq_3.monthly_ds__quarter AS monthly_ds__quarter + , subq_3.monthly_ds__year AS monthly_ds__year + , subq_3.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_3.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_3.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_3.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_3.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_3.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_3.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_3.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_3.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_3.listing AS listing + , subq_3.booking__listing AS booking__listing + , subq_3.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_3.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_3 + DATE_TRUNC('month', subq_5.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_5 GROUP BY - DATE_TRUNC('month', subq_3.ds) - ) subq_2 + DATE_TRUNC('month', subq_5.ds) + ) subq_4 INNER JOIN ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_2.monthly_ds__month + , subq_2.monthly_ds__quarter + , subq_2.monthly_ds__year + , subq_2.monthly_ds__extract_year + , subq_2.monthly_ds__extract_quarter + , subq_2.monthly_ds__extract_month + , subq_2.booking__monthly_ds__month + , subq_2.booking__monthly_ds__quarter + , subq_2.booking__monthly_ds__year + , subq_2.booking__monthly_ds__extract_year + , subq_2.booking__monthly_ds__extract_quarter + , subq_2.booking__monthly_ds__extract_month + , subq_2.monthly_ds__month AS metric_time__month + , subq_2.monthly_ds__quarter AS metric_time__quarter + , subq_2.monthly_ds__year AS metric_time__year + , subq_2.monthly_ds__extract_year AS metric_time__extract_year + , subq_2.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_2.monthly_ds__extract_month AS metric_time__extract_month + , subq_2.listing + , subq_2.booking__listing + , subq_2.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -87,13 +87,13 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 + ) subq_2 + ) subq_3 ON - DATEADD(month, -1, subq_2.metric_time__month) = subq_1.metric_time__month - ) subq_4 - ) subq_5 + DATEADD(month, -1, subq_4.metric_time__month) = subq_3.metric_time__month + ) subq_6 + ) subq_7 GROUP BY - subq_5.metric_time__month - ) subq_6 -) subq_7 + subq_7.metric_time__month + ) subq_8 +) subq_9 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index ccd562cfa6..75916f38d4 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -8,20 +8,20 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month AS metric_time__month + subq_12.metric_time__month AS metric_time__month , SUM(bookings_monthly_source_src_16000.bookings_monthly) AS bookings_last_month FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_13 GROUP BY DATE_TRUNC('month', ds) - ) subq_10 + ) subq_12 INNER JOIN ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 ON - DATEADD(month, -1, subq_10.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_16000.ds) + DATEADD(month, -1, subq_12.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_16000.ds) GROUP BY - subq_10.metric_time__month -) subq_15 + subq_12.metric_time__month +) subq_17 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql index abe671054c..75c7999289 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__day - ) subq_11 - ) subq_12 + subq_19.metric_time__day + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) -) subq_13 + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 5138fe8ae6..2061be23cf 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day + DATE_TRUNC('month', subq_31.ds) = subq_29.metric_time__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) -) subq_27 + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index 7657920261..ff45580a66 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -1,546 +1,546 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__week + subq_22.metric_time__week , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) AS metric_time__week - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__week, subq_21.metric_time__week) AS metric_time__week + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__week - , subq_3.bookings + subq_12.metric_time__week + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__week - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__week + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_1.metric_time__week - , subq_1.bookings + subq_10.metric_time__week + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__week - ) subq_3 - ) subq_4 + subq_11.metric_time__week + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__week - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__week + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__week - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__week + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_9.metric_time__week - , subq_9.bookings + subq_18.metric_time__week + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('week', subq_7.metric_time__day) AS metric_time__week - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('week', subq_16.metric_time__day) AS metric_time__week + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.metric_time__day) = subq_6.metric_time__day - WHERE DATE_TRUNC('week', subq_7.metric_time__day) = subq_7.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.metric_time__day) = subq_15.metric_time__day + WHERE DATE_TRUNC('week', subq_16.metric_time__day) = subq_16.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__week - ) subq_11 - ) subq_12 + subq_19.metric_time__week + ) subq_20 + ) subq_21 ON - subq_4.metric_time__week = subq_12.metric_time__week + subq_13.metric_time__week = subq_21.metric_time__week GROUP BY - COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) -) subq_13 + COALESCE(subq_13.metric_time__week, subq_21.metric_time__week) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index b9e4162413..65cf132abd 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) AS metric_time__week - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__week, subq_35.metric_time__week) AS metric_time__week + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,36 +21,36 @@ FROM ( SELECT DATE_TRUNC('week', ds) AS metric_time__week , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__week - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__week'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('week', subq_22.ds) AS metric_time__week - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC('week', subq_31.ds) AS metric_time__week + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day - WHERE DATE_TRUNC('week', subq_22.ds) = subq_22.ds + DATE_TRUNC('month', subq_31.ds) = subq_29.metric_time__day + WHERE DATE_TRUNC('week', subq_31.ds) = subq_31.ds GROUP BY - DATE_TRUNC('week', subq_22.ds) - ) subq_26 + DATE_TRUNC('week', subq_31.ds) + ) subq_35 ON - subq_18.metric_time__week = subq_26.metric_time__week + subq_27.metric_time__week = subq_35.metric_time__week GROUP BY - COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) -) subq_27 + COALESCE(subq_27.metric_time__week, subq_35.metric_time__week) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql index 5ff5134d8e..142f8ff9a1 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATEADD(day, -14, subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATEADD(day, -14, subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__day - ) subq_11 - ) subq_12 + subq_19.metric_time__day + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) -) subq_13 + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql index 197f4d5430..ba542c8a14 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_31.ds) = subq_29.metric_time__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) -) subq_27 + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 496cd41b91..b88129dbee 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__quarter + subq_22.metric_time__quarter , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) AS metric_time__quarter - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__quarter, subq_21.metric_time__quarter) AS metric_time__quarter + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__quarter - , subq_3.bookings + subq_12.metric_time__quarter + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__quarter - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__quarter + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_1.metric_time__quarter - , subq_1.bookings + subq_10.metric_time__quarter + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__quarter - ) subq_3 - ) subq_4 + subq_11.metric_time__quarter + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__quarter - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__quarter + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__quarter - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__quarter + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_9.metric_time__quarter - , subq_9.bookings + subq_18.metric_time__quarter + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('quarter', subq_7.metric_time__day) AS metric_time__quarter - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('quarter', subq_16.metric_time__day) AS metric_time__quarter + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATEADD(day, -14, subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATEADD(day, -14, subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__quarter - ) subq_11 - ) subq_12 + subq_19.metric_time__quarter + ) subq_20 + ) subq_21 ON - subq_4.metric_time__quarter = subq_12.metric_time__quarter + subq_13.metric_time__quarter = subq_21.metric_time__quarter GROUP BY - COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) -) subq_13 + COALESCE(subq_13.metric_time__quarter, subq_21.metric_time__quarter) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index 89f6dcf4d2..d31ffad9a6 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) AS metric_time__quarter - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__quarter, subq_35.metric_time__quarter) AS metric_time__quarter + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('quarter', ds) AS metric_time__quarter , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__quarter - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__quarter'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('quarter', subq_22.ds) AS metric_time__quarter - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC('quarter', subq_31.ds) AS metric_time__quarter + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_31.ds) = subq_29.metric_time__day GROUP BY - DATE_TRUNC('quarter', subq_22.ds) - ) subq_26 + DATE_TRUNC('quarter', subq_31.ds) + ) subq_35 ON - subq_18.metric_time__quarter = subq_26.metric_time__quarter + subq_27.metric_time__quarter = subq_35.metric_time__quarter GROUP BY - COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) -) subq_27 + COALESCE(subq_27.metric_time__quarter, subq_35.metric_time__quarter) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 0be63111b8..ff4fa7f076 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -1,645 +1,645 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__day + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC('month', subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 + subq_14.metric_time__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATEADD(month, -1, subq_10.metric_time__day) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATEADD(month, -1, subq_19.metric_time__day) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__day - ) subq_14 - ) subq_15 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) -) subq_16 + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 1f8ce4023a..bedc1e94c6 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -5,55 +5,55 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_20.ds AS metric_time__day - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + subq_29.ds AS metric_time__day + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day + DATE_TRUNC('month', subq_29.ds) = subq_27.metric_time__day GROUP BY - subq_20.ds - ) subq_24 + subq_29.ds + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATEADD(month, -1, subq_28.ds) = subq_26.metric_time__day + DATEADD(month, -1, subq_37.ds) = subq_35.metric_time__day GROUP BY - subq_28.ds - ) subq_32 + subq_37.ds + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 7b9d63c675..6e1e9f0f6b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -1,646 +1,646 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__year + subq_25.metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) AS metric_time__year - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__year, subq_24.metric_time__year) AS metric_time__year + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__year - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__year + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__year - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__year + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_4.metric_time__year - , subq_4.bookings + subq_13.metric_time__year + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('year', subq_11.metric_time__day) AS metric_time__year + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - WHERE DATE_TRUNC('year', subq_2.metric_time__day) = subq_2.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC('month', subq_11.metric_time__day) = subq_10.metric_time__day + WHERE DATE_TRUNC('year', subq_11.metric_time__day) = subq_11.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__year - ) subq_6 - ) subq_7 + subq_14.metric_time__year + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__year - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__year + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__year - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__year + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_12.metric_time__year - , subq_12.bookings + subq_21.metric_time__year + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_10.metric_time__day) AS metric_time__year - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('year', subq_19.metric_time__day) AS metric_time__year + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATEADD(month, -1, subq_10.metric_time__day) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATEADD(month, -1, subq_19.metric_time__day) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__year - ) subq_14 - ) subq_15 + subq_22.metric_time__year + ) subq_23 + ) subq_24 ON - subq_7.metric_time__year = subq_15.metric_time__year + subq_16.metric_time__year = subq_24.metric_time__year GROUP BY - COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) -) subq_16 + COALESCE(subq_16.metric_time__year, subq_24.metric_time__year) +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 6df1bd72d2..3b62cf5d4b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,56 +5,56 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) AS metric_time__year - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__year, subq_41.metric_time__year) AS metric_time__year + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_20.ds) AS metric_time__year - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + DATE_TRUNC('year', subq_29.ds) AS metric_time__year + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day - WHERE DATE_TRUNC('year', subq_20.ds) = subq_20.ds + DATE_TRUNC('month', subq_29.ds) = subq_27.metric_time__day + WHERE DATE_TRUNC('year', subq_29.ds) = subq_29.ds GROUP BY - DATE_TRUNC('year', subq_20.ds) - ) subq_24 + DATE_TRUNC('year', subq_29.ds) + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_28.ds) AS metric_time__year - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + DATE_TRUNC('year', subq_37.ds) AS metric_time__year + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATEADD(month, -1, subq_28.ds) = subq_26.metric_time__day + DATEADD(month, -1, subq_37.ds) = subq_35.metric_time__day GROUP BY - DATE_TRUNC('year', subq_28.ds) - ) subq_32 + DATE_TRUNC('year', subq_37.ds) + ) subq_41 ON - subq_24.metric_time__year = subq_32.metric_time__year + subq_33.metric_time__year = subq_41.metric_time__year GROUP BY - COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) -) subq_33 + COALESCE(subq_33.metric_time__year, subq_41.metric_time__year) +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index a1e9adacf4..1e2f38e545 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_5.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_5.bookings) AS bookings - , MAX(subq_14.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_14.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_14.bookings) AS bookings + , MAX(subq_23.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_3.metric_time__day - , SUM(subq_3.bookings) AS bookings + subq_12.metric_time__day + , SUM(subq_12.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.bookings + subq_11.metric_time__day + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_3 + ) subq_12 GROUP BY - subq_3.metric_time__day - ) subq_4 - ) subq_5 + subq_12.metric_time__day + ) subq_13 + ) subq_14 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.bookings AS bookings_2_weeks_ago + subq_22.metric_time__day + , subq_22.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.bookings) AS bookings + subq_21.metric_time__day + , SUM(subq_21.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings + subq_20.metric_time__day + , subq_20.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_19.metric_time__day + , subq_19.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.ds__day AS ds__day - , subq_7.ds__week AS ds__week - , subq_7.ds__month AS ds__month - , subq_7.ds__quarter AS ds__quarter - , subq_7.ds__year AS ds__year - , subq_7.ds__extract_year AS ds__extract_year - , subq_7.ds__extract_quarter AS ds__extract_quarter - , subq_7.ds__extract_month AS ds__extract_month - , subq_7.ds__extract_day AS ds__extract_day - , subq_7.ds__extract_dow AS ds__extract_dow - , subq_7.ds__extract_doy AS ds__extract_doy - , subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__week AS ds_partitioned__week - , subq_7.ds_partitioned__month AS ds_partitioned__month - , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_7.ds_partitioned__year AS ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_7.paid_at__day AS paid_at__day - , subq_7.paid_at__week AS paid_at__week - , subq_7.paid_at__month AS paid_at__month - , subq_7.paid_at__quarter AS paid_at__quarter - , subq_7.paid_at__year AS paid_at__year - , subq_7.paid_at__extract_year AS paid_at__extract_year - , subq_7.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_7.paid_at__extract_month AS paid_at__extract_month - , subq_7.paid_at__extract_day AS paid_at__extract_day - , subq_7.paid_at__extract_dow AS paid_at__extract_dow - , subq_7.paid_at__extract_doy AS paid_at__extract_doy - , subq_7.booking__ds__day AS booking__ds__day - , subq_7.booking__ds__week AS booking__ds__week - , subq_7.booking__ds__month AS booking__ds__month - , subq_7.booking__ds__quarter AS booking__ds__quarter - , subq_7.booking__ds__year AS booking__ds__year - , subq_7.booking__ds__extract_year AS booking__ds__extract_year - , subq_7.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_7.booking__ds__extract_month AS booking__ds__extract_month - , subq_7.booking__ds__extract_day AS booking__ds__extract_day - , subq_7.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_7.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day AS booking__paid_at__day - , subq_7.booking__paid_at__week AS booking__paid_at__week - , subq_7.booking__paid_at__month AS booking__paid_at__month - , subq_7.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_7.booking__paid_at__year AS booking__paid_at__year - , subq_7.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_7.listing AS listing - , subq_7.guest AS guest - , subq_7.host AS host - , subq_7.booking__listing AS booking__listing - , subq_7.booking__guest AS booking__guest - , subq_7.booking__host AS booking__host - , subq_7.is_instant AS is_instant - , subq_7.booking__is_instant AS booking__is_instant - , subq_7.bookings AS bookings - , subq_7.instant_bookings AS instant_bookings - , subq_7.booking_value AS booking_value - , subq_7.max_booking_value AS max_booking_value - , subq_7.min_booking_value AS min_booking_value - , subq_7.bookers AS bookers - , subq_7.average_booking_value AS average_booking_value - , subq_7.referred_bookings AS referred_bookings - , subq_7.median_booking_value AS median_booking_value - , subq_7.booking_value_p99 AS booking_value_p99 - , subq_7.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_17.metric_time__day AS metric_time__day + , subq_16.ds__day AS ds__day + , subq_16.ds__week AS ds__week + , subq_16.ds__month AS ds__month + , subq_16.ds__quarter AS ds__quarter + , subq_16.ds__year AS ds__year + , subq_16.ds__extract_year AS ds__extract_year + , subq_16.ds__extract_quarter AS ds__extract_quarter + , subq_16.ds__extract_month AS ds__extract_month + , subq_16.ds__extract_day AS ds__extract_day + , subq_16.ds__extract_dow AS ds__extract_dow + , subq_16.ds__extract_doy AS ds__extract_doy + , subq_16.ds_partitioned__day AS ds_partitioned__day + , subq_16.ds_partitioned__week AS ds_partitioned__week + , subq_16.ds_partitioned__month AS ds_partitioned__month + , subq_16.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_16.ds_partitioned__year AS ds_partitioned__year + , subq_16.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_16.paid_at__day AS paid_at__day + , subq_16.paid_at__week AS paid_at__week + , subq_16.paid_at__month AS paid_at__month + , subq_16.paid_at__quarter AS paid_at__quarter + , subq_16.paid_at__year AS paid_at__year + , subq_16.paid_at__extract_year AS paid_at__extract_year + , subq_16.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_16.paid_at__extract_month AS paid_at__extract_month + , subq_16.paid_at__extract_day AS paid_at__extract_day + , subq_16.paid_at__extract_dow AS paid_at__extract_dow + , subq_16.paid_at__extract_doy AS paid_at__extract_doy + , subq_16.booking__ds__day AS booking__ds__day + , subq_16.booking__ds__week AS booking__ds__week + , subq_16.booking__ds__month AS booking__ds__month + , subq_16.booking__ds__quarter AS booking__ds__quarter + , subq_16.booking__ds__year AS booking__ds__year + , subq_16.booking__ds__extract_year AS booking__ds__extract_year + , subq_16.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_16.booking__ds__extract_month AS booking__ds__extract_month + , subq_16.booking__ds__extract_day AS booking__ds__extract_day + , subq_16.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_16.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day AS booking__paid_at__day + , subq_16.booking__paid_at__week AS booking__paid_at__week + , subq_16.booking__paid_at__month AS booking__paid_at__month + , subq_16.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_16.booking__paid_at__year AS booking__paid_at__year + , subq_16.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_16.listing AS listing + , subq_16.guest AS guest + , subq_16.host AS host + , subq_16.booking__listing AS booking__listing + , subq_16.booking__guest AS booking__guest + , subq_16.booking__host AS booking__host + , subq_16.is_instant AS is_instant + , subq_16.booking__is_instant AS booking__is_instant + , subq_16.bookings AS bookings + , subq_16.instant_bookings AS instant_bookings + , subq_16.booking_value AS booking_value + , subq_16.max_booking_value AS max_booking_value + , subq_16.min_booking_value AS min_booking_value + , subq_16.bookers AS bookers + , subq_16.average_booking_value AS average_booking_value + , subq_16.referred_bookings AS referred_bookings + , subq_16.median_booking_value AS median_booking_value + , subq_16.booking_value_p99 AS booking_value_p99 + , subq_16.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_16.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - ) subq_8 + subq_18.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + ) subq_17 INNER JOIN ( -- 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_15.ds__day + , subq_15.ds__week + , subq_15.ds__month + , subq_15.ds__quarter + , subq_15.ds__year + , subq_15.ds__extract_year + , subq_15.ds__extract_quarter + , subq_15.ds__extract_month + , subq_15.ds__extract_day + , subq_15.ds__extract_dow + , subq_15.ds__extract_doy + , subq_15.ds_partitioned__day + , subq_15.ds_partitioned__week + , subq_15.ds_partitioned__month + , subq_15.ds_partitioned__quarter + , subq_15.ds_partitioned__year + , subq_15.ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy + , subq_15.paid_at__day + , subq_15.paid_at__week + , subq_15.paid_at__month + , subq_15.paid_at__quarter + , subq_15.paid_at__year + , subq_15.paid_at__extract_year + , subq_15.paid_at__extract_quarter + , subq_15.paid_at__extract_month + , subq_15.paid_at__extract_day + , subq_15.paid_at__extract_dow + , subq_15.paid_at__extract_doy + , subq_15.booking__ds__day + , subq_15.booking__ds__week + , subq_15.booking__ds__month + , subq_15.booking__ds__quarter + , subq_15.booking__ds__year + , subq_15.booking__ds__extract_year + , subq_15.booking__ds__extract_quarter + , subq_15.booking__ds__extract_month + , subq_15.booking__ds__extract_day + , subq_15.booking__ds__extract_dow + , subq_15.booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day + , subq_15.booking__paid_at__week + , subq_15.booking__paid_at__month + , subq_15.booking__paid_at__quarter + , subq_15.booking__paid_at__year + , subq_15.booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy + , subq_15.ds__day AS metric_time__day + , subq_15.ds__week AS metric_time__week + , subq_15.ds__month AS metric_time__month + , subq_15.ds__quarter AS metric_time__quarter + , subq_15.ds__year AS metric_time__year + , subq_15.ds__extract_year AS metric_time__extract_year + , subq_15.ds__extract_quarter AS metric_time__extract_quarter + , subq_15.ds__extract_month AS metric_time__extract_month + , subq_15.ds__extract_day AS metric_time__extract_day + , subq_15.ds__extract_dow AS metric_time__extract_dow + , subq_15.ds__extract_doy AS metric_time__extract_doy + , subq_15.listing + , subq_15.guest + , subq_15.host + , subq_15.booking__listing + , subq_15.booking__guest + , subq_15.booking__host + , subq_15.is_instant + , subq_15.booking__is_instant + , subq_15.bookings + , subq_15.instant_bookings + , subq_15.booking_value + , subq_15.max_booking_value + , subq_15.min_booking_value + , subq_15.bookers + , subq_15.average_booking_value + , subq_15.referred_bookings + , subq_15.median_booking_value + , subq_15.booking_value_p99 + , subq_15.discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 + , subq_15.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 - ) subq_7 + , 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_15 + ) subq_16 ON - DATEADD(day, -14, subq_8.metric_time__day) = subq_7.metric_time__day - ) subq_10 - ) subq_11 + DATEADD(day, -14, subq_17.metric_time__day) = subq_16.metric_time__day + ) subq_19 + ) subq_20 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_12 + ) subq_21 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_21.metric_time__day + ) subq_22 + ) subq_23 ON - subq_5.metric_time__day = subq_14.metric_time__day + subq_14.metric_time__day = subq_23.metric_time__day GROUP BY - COALESCE(subq_5.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_14.metric_time__day, subq_23.metric_time__day) +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 526089b4ce..e4dc96227a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_21.bookings) AS bookings - , MAX(subq_30.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_30.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_30.bookings) AS bookings + , MAX(subq_39.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -22,12 +22,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_21 + ) subq_30 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -39,26 +39,26 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_25.ds AS metric_time__day - , subq_23.bookings AS bookings - FROM ***************************.mf_time_spine subq_25 + subq_34.ds AS metric_time__day + , subq_32.bookings AS bookings + FROM ***************************.mf_time_spine subq_34 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 ON - DATEADD(day, -14, subq_25.ds) = subq_23.metric_time__day - ) subq_27 + DATEADD(day, -14, subq_34.ds) = subq_32.metric_time__day + ) subq_36 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_30 + ) subq_39 ON - subq_21.metric_time__day = subq_30.metric_time__day + subq_30.metric_time__day = subq_39.metric_time__day GROUP BY - COALESCE(subq_21.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_30.metric_time__day, subq_39.metric_time__day) +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql index c010b8557b..25ba004024 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql @@ -1,433 +1,433 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookers AS every_2_days_bookers_2_days_ago + subq_18.metric_time__day + , subq_18.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , COUNT(DISTINCT subq_8.bookers) AS bookers + subq_17.metric_time__day + , COUNT(DISTINCT subq_17.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -2, subq_11.metric_time__day) ) - ) subq_4 + ) subq_13 ON - DATEADD(day, -2, subq_5.metric_time__day) = subq_4.metric_time__day - ) subq_7 - ) subq_8 + DATEADD(day, -2, subq_14.metric_time__day) = subq_13.metric_time__day + ) subq_16 + ) subq_17 GROUP BY - subq_8.metric_time__day - ) subq_9 -) subq_10 + subq_17.metric_time__day + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0_optimized.sql index 866ba0a41b..d5e3a9771e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -8,26 +8,26 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , COUNT(DISTINCT subq_15.bookers) AS every_2_days_bookers_2_days_ago - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , COUNT(DISTINCT subq_24.bookers) AS every_2_days_bookers_2_days_ago + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_14.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_14 + subq_23.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_23 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_23.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATEADD(day, -2, subq_14.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_23.ds) ) - ) subq_15 + ) subq_24 ON - DATEADD(day, -2, subq_17.ds) = subq_15.metric_time__day + DATEADD(day, -2, subq_26.ds) = subq_24.metric_time__day GROUP BY - subq_17.ds -) subq_21 + subq_26.ds +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0.sql index d04e53e5ae..1b38082c4e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_7.booking_value) AS booking_value - , MAX(subq_12.bookers) AS bookers + COALESCE(subq_16.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_16.booking_value) AS booking_value + , MAX(subq_21.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_6.booking__ds__day - , subq_6.booking_value + subq_15.booking__ds__day + , subq_15.booking_value FROM ( -- Aggregate Measures SELECT - subq_5.booking__ds__day - , SUM(subq_5.booking_value) AS booking_value + subq_14.booking__ds__day + , SUM(subq_14.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__ds__day'] SELECT - subq_4.booking__ds__day - , subq_4.booking_value + subq_13.booking__ds__day + , subq_13.booking_value FROM ( -- Join to Time Spine Dataset SELECT - subq_2.booking__ds__day AS booking__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.booking__ds__day AS booking__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(week, -1, subq_2.booking__ds__day) = subq_1.booking__ds__day - ) subq_4 - ) subq_5 + DATEADD(week, -1, subq_11.booking__ds__day) = subq_10.booking__ds__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.booking__ds__day - ) subq_6 - ) subq_7 + subq_14.booking__ds__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookers + subq_20.booking__ds__day + , subq_20.bookers FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , COUNT(DISTINCT subq_10.bookers) AS bookers + subq_19.booking__ds__day + , COUNT(DISTINCT subq_19.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookers + subq_18.booking__ds__day + , subq_18.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 - ) subq_10 + , 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_17 + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_7.booking__ds__day = subq_12.booking__ds__day + subq_16.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_7.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_16.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql index 085c58e4f4..0edb7a0c7b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql @@ -5,25 +5,25 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_21.booking_value) AS booking_value - , MAX(subq_26.bookers) AS bookers + COALESCE(subq_30.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_30.booking_value) AS booking_value + , MAX(subq_35.bookers) AS bookers FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['booking_value', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS booking__ds__day - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS booking__ds__day + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.mf_time_spine subq_26 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_17.ds) = DATE_TRUNC('day', bookings_source_src_28001.ds) + DATEADD(week, -1, subq_26.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds - ) subq_21 + subq_26.ds + ) subq_30 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -33,12 +33,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , COUNT(DISTINCT guest_id) AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_26 + ) subq_35 ON - subq_21.booking__ds__day = subq_26.booking__ds__day + subq_30.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_21.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_30.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql index b988557a93..fd80e3bb17 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -1,319 +1,319 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 -) subq_7 + subq_14.metric_time__day + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 56f1d26f59..1a6402a3bb 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -8,19 +8,19 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago + FROM ***************************.mf_time_spine subq_20 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - DATEADD(day, -5, subq_11.ds) = subq_9.metric_time__day + DATEADD(day, -5, subq_20.ds) = subq_18.metric_time__day GROUP BY - subq_11.ds -) subq_15 + subq_20.ds +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0.sql index 9cf45debd4..d696778296 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0.sql @@ -1,895 +1,895 @@ -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day + subq_31.metric_time__day , non_referred + (instant * 1.0 / bookings) AS instant_plus_non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) AS metric_time__day - , MAX(subq_11.non_referred) AS non_referred - , MAX(subq_16.instant) AS instant - , MAX(subq_21.bookings) AS bookings + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day + , MAX(subq_20.non_referred) AS non_referred + , MAX(subq_25.instant) AS instant + , MAX(subq_30.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_16.metric_time__day + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) - ) subq_10 - ) subq_11 + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day - , subq_15.instant_bookings AS instant + subq_24.metric_time__day + , subq_24.instant_bookings AS instant FROM ( -- Aggregate Measures SELECT - subq_14.metric_time__day - , SUM(subq_14.instant_bookings) AS instant_bookings + subq_23.metric_time__day + , SUM(subq_23.instant_bookings) AS instant_bookings FROM ( -- Pass Only Elements: ['instant_bookings', 'metric_time__day'] SELECT - subq_13.metric_time__day - , subq_13.instant_bookings + subq_22.metric_time__day + , subq_22.instant_bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 GROUP BY - subq_14.metric_time__day - ) subq_15 - ) subq_16 + subq_23.metric_time__day + ) subq_24 + ) subq_25 ON - subq_11.metric_time__day = subq_16.metric_time__day + subq_20.metric_time__day = subq_25.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Aggregate Measures SELECT - subq_19.metric_time__day - , SUM(subq_19.bookings) AS bookings + subq_28.metric_time__day + , SUM(subq_28.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.bookings + subq_27.metric_time__day + , subq_27.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_17.ds__day - , subq_17.ds__week - , subq_17.ds__month - , subq_17.ds__quarter - , subq_17.ds__year - , subq_17.ds__extract_year - , subq_17.ds__extract_quarter - , subq_17.ds__extract_month - , subq_17.ds__extract_day - , subq_17.ds__extract_dow - , subq_17.ds__extract_doy - , subq_17.ds_partitioned__day - , subq_17.ds_partitioned__week - , subq_17.ds_partitioned__month - , subq_17.ds_partitioned__quarter - , subq_17.ds_partitioned__year - , subq_17.ds_partitioned__extract_year - , subq_17.ds_partitioned__extract_quarter - , subq_17.ds_partitioned__extract_month - , subq_17.ds_partitioned__extract_day - , subq_17.ds_partitioned__extract_dow - , subq_17.ds_partitioned__extract_doy - , subq_17.paid_at__day - , subq_17.paid_at__week - , subq_17.paid_at__month - , subq_17.paid_at__quarter - , subq_17.paid_at__year - , subq_17.paid_at__extract_year - , subq_17.paid_at__extract_quarter - , subq_17.paid_at__extract_month - , subq_17.paid_at__extract_day - , subq_17.paid_at__extract_dow - , subq_17.paid_at__extract_doy - , subq_17.booking__ds__day - , subq_17.booking__ds__week - , subq_17.booking__ds__month - , subq_17.booking__ds__quarter - , subq_17.booking__ds__year - , subq_17.booking__ds__extract_year - , subq_17.booking__ds__extract_quarter - , subq_17.booking__ds__extract_month - , subq_17.booking__ds__extract_day - , subq_17.booking__ds__extract_dow - , subq_17.booking__ds__extract_doy - , subq_17.booking__ds_partitioned__day - , subq_17.booking__ds_partitioned__week - , subq_17.booking__ds_partitioned__month - , subq_17.booking__ds_partitioned__quarter - , subq_17.booking__ds_partitioned__year - , subq_17.booking__ds_partitioned__extract_year - , subq_17.booking__ds_partitioned__extract_quarter - , subq_17.booking__ds_partitioned__extract_month - , subq_17.booking__ds_partitioned__extract_day - , subq_17.booking__ds_partitioned__extract_dow - , subq_17.booking__ds_partitioned__extract_doy - , subq_17.booking__paid_at__day - , subq_17.booking__paid_at__week - , subq_17.booking__paid_at__month - , subq_17.booking__paid_at__quarter - , subq_17.booking__paid_at__year - , subq_17.booking__paid_at__extract_year - , subq_17.booking__paid_at__extract_quarter - , subq_17.booking__paid_at__extract_month - , subq_17.booking__paid_at__extract_day - , subq_17.booking__paid_at__extract_dow - , subq_17.booking__paid_at__extract_doy - , subq_17.ds__day AS metric_time__day - , subq_17.ds__week AS metric_time__week - , subq_17.ds__month AS metric_time__month - , subq_17.ds__quarter AS metric_time__quarter - , subq_17.ds__year AS metric_time__year - , subq_17.ds__extract_year AS metric_time__extract_year - , subq_17.ds__extract_quarter AS metric_time__extract_quarter - , subq_17.ds__extract_month AS metric_time__extract_month - , subq_17.ds__extract_day AS metric_time__extract_day - , subq_17.ds__extract_dow AS metric_time__extract_dow - , subq_17.ds__extract_doy AS metric_time__extract_doy - , subq_17.listing - , subq_17.guest - , subq_17.host - , subq_17.booking__listing - , subq_17.booking__guest - , subq_17.booking__host - , subq_17.is_instant - , subq_17.booking__is_instant - , subq_17.bookings - , subq_17.instant_bookings - , subq_17.booking_value - , subq_17.max_booking_value - , subq_17.min_booking_value - , subq_17.bookers - , subq_17.average_booking_value - , subq_17.referred_bookings - , subq_17.median_booking_value - , subq_17.booking_value_p99 - , subq_17.discrete_booking_value_p99 - , subq_17.approximate_continuous_booking_value_p99 - , subq_17.approximate_discrete_booking_value_p99 + subq_26.ds__day + , subq_26.ds__week + , subq_26.ds__month + , subq_26.ds__quarter + , subq_26.ds__year + , subq_26.ds__extract_year + , subq_26.ds__extract_quarter + , subq_26.ds__extract_month + , subq_26.ds__extract_day + , subq_26.ds__extract_dow + , subq_26.ds__extract_doy + , subq_26.ds_partitioned__day + , subq_26.ds_partitioned__week + , subq_26.ds_partitioned__month + , subq_26.ds_partitioned__quarter + , subq_26.ds_partitioned__year + , subq_26.ds_partitioned__extract_year + , subq_26.ds_partitioned__extract_quarter + , subq_26.ds_partitioned__extract_month + , subq_26.ds_partitioned__extract_day + , subq_26.ds_partitioned__extract_dow + , subq_26.ds_partitioned__extract_doy + , subq_26.paid_at__day + , subq_26.paid_at__week + , subq_26.paid_at__month + , subq_26.paid_at__quarter + , subq_26.paid_at__year + , subq_26.paid_at__extract_year + , subq_26.paid_at__extract_quarter + , subq_26.paid_at__extract_month + , subq_26.paid_at__extract_day + , subq_26.paid_at__extract_dow + , subq_26.paid_at__extract_doy + , subq_26.booking__ds__day + , subq_26.booking__ds__week + , subq_26.booking__ds__month + , subq_26.booking__ds__quarter + , subq_26.booking__ds__year + , subq_26.booking__ds__extract_year + , subq_26.booking__ds__extract_quarter + , subq_26.booking__ds__extract_month + , subq_26.booking__ds__extract_day + , subq_26.booking__ds__extract_dow + , subq_26.booking__ds__extract_doy + , subq_26.booking__ds_partitioned__day + , subq_26.booking__ds_partitioned__week + , subq_26.booking__ds_partitioned__month + , subq_26.booking__ds_partitioned__quarter + , subq_26.booking__ds_partitioned__year + , subq_26.booking__ds_partitioned__extract_year + , subq_26.booking__ds_partitioned__extract_quarter + , subq_26.booking__ds_partitioned__extract_month + , subq_26.booking__ds_partitioned__extract_day + , subq_26.booking__ds_partitioned__extract_dow + , subq_26.booking__ds_partitioned__extract_doy + , subq_26.booking__paid_at__day + , subq_26.booking__paid_at__week + , subq_26.booking__paid_at__month + , subq_26.booking__paid_at__quarter + , subq_26.booking__paid_at__year + , subq_26.booking__paid_at__extract_year + , subq_26.booking__paid_at__extract_quarter + , subq_26.booking__paid_at__extract_month + , subq_26.booking__paid_at__extract_day + , subq_26.booking__paid_at__extract_dow + , subq_26.booking__paid_at__extract_doy + , subq_26.ds__day AS metric_time__day + , subq_26.ds__week AS metric_time__week + , subq_26.ds__month AS metric_time__month + , subq_26.ds__quarter AS metric_time__quarter + , subq_26.ds__year AS metric_time__year + , subq_26.ds__extract_year AS metric_time__extract_year + , subq_26.ds__extract_quarter AS metric_time__extract_quarter + , subq_26.ds__extract_month AS metric_time__extract_month + , subq_26.ds__extract_day AS metric_time__extract_day + , subq_26.ds__extract_dow AS metric_time__extract_dow + , subq_26.ds__extract_doy AS metric_time__extract_doy + , subq_26.listing + , subq_26.guest + , subq_26.host + , subq_26.booking__listing + , subq_26.booking__guest + , subq_26.booking__host + , subq_26.is_instant + , subq_26.booking__is_instant + , subq_26.bookings + , subq_26.instant_bookings + , subq_26.booking_value + , subq_26.max_booking_value + , subq_26.min_booking_value + , subq_26.bookers + , subq_26.average_booking_value + , subq_26.referred_bookings + , subq_26.median_booking_value + , subq_26.booking_value_p99 + , subq_26.discrete_booking_value_p99 + , subq_26.approximate_continuous_booking_value_p99 + , subq_26.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_17 - ) subq_18 - ) subq_19 + , 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_26 + ) subq_27 + ) subq_28 GROUP BY - subq_19.metric_time__day - ) subq_20 - ) subq_21 + subq_28.metric_time__day + ) subq_29 + ) subq_30 ON - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day) = subq_21.metric_time__day + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day) = subq_30.metric_time__day GROUP BY - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) -) subq_22 + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day, subq_30.metric_time__day) +) subq_31 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0_optimized.sql index 78837fdd96..da1e9fdd5a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) AS metric_time__day - , MAX(subq_34.non_referred) AS non_referred - , MAX(subq_39.instant) AS instant - , MAX(subq_44.bookings) AS bookings + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day, subq_53.metric_time__day) AS metric_time__day + , MAX(subq_43.non_referred) AS non_referred + , MAX(subq_48.instant) AS instant + , MAX(subq_53.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -17,9 +17,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.ref_bookings) AS ref_bookings - , MAX(subq_32.bookings) AS bookings + COALESCE(subq_36.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_36.ref_bookings) AS ref_bookings + , MAX(subq_41.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -33,11 +33,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_25 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_34 GROUP BY metric_time__day - ) subq_27 + ) subq_36 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -51,17 +51,17 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_30 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_39 GROUP BY metric_time__day - ) subq_32 + ) subq_41 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_36.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) - ) subq_33 - ) subq_34 + COALESCE(subq_36.metric_time__day, subq_41.metric_time__day) + ) subq_42 + ) subq_43 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -75,13 +75,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_37 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_46 GROUP BY metric_time__day - ) subq_39 + ) subq_48 ON - subq_34.metric_time__day = subq_39.metric_time__day + subq_43.metric_time__day = subq_48.metric_time__day FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -95,13 +95,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_42 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_51 GROUP BY metric_time__day - ) subq_44 + ) subq_53 ON - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day) = subq_44.metric_time__day + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day) = subq_53.metric_time__day GROUP BY - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) -) subq_45 + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day, subq_53.metric_time__day) +) subq_54 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index ab6f852ebf..a1659c6769 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -1,359 +1,359 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Pass Only Elements: ['metric_time__day', 'bookings_offset_once'] SELECT - subq_12.metric_time__day - , subq_12.bookings_offset_once + subq_21.metric_time__day + , subq_21.bookings_offset_once FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.booking__is_instant - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.booking__is_instant + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.booking__is_instant AS booking__is_instant - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.booking__is_instant AS booking__is_instant + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant + subq_16.metric_time__day + , subq_16.booking__is_instant , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.bookings + subq_15.metric_time__day + , subq_15.booking__is_instant + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , subq_14.booking__is_instant + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_13.metric_time__day + , subq_13.booking__is_instant + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - , subq_5.booking__is_instant - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + , subq_14.booking__is_instant + ) subq_15 + ) subq_16 + ) subq_17 ON - DATEADD(day, -2, subq_9.metric_time__day) = subq_8.metric_time__day - ) subq_11 + DATEADD(day, -2, subq_18.metric_time__day) = subq_17.metric_time__day + ) subq_20 WHERE booking__is_instant - ) subq_12 -) subq_13 + ) subq_21 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index 611927c9a2..558939c098 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -11,10 +11,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_24.ds AS metric_time__day - , subq_22.booking__is_instant AS booking__is_instant - , subq_22.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_24 + subq_33.ds AS metric_time__day + , subq_31.booking__is_instant AS booking__is_instant + , subq_31.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_33 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -27,10 +27,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , subq_15.booking__is_instant AS booking__is_instant - , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , subq_24.booking__is_instant AS booking__is_instant + , SUM(subq_24.bookings) AS bookings + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -38,17 +38,17 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 ON - DATEADD(day, -5, subq_17.ds) = subq_15.metric_time__day + DATEADD(day, -5, subq_26.ds) = subq_24.metric_time__day GROUP BY - subq_17.ds - , subq_15.booking__is_instant - ) subq_21 - ) subq_22 + subq_26.ds + , subq_24.booking__is_instant + ) subq_30 + ) subq_31 ON - DATEADD(day, -2, subq_24.ds) = subq_22.metric_time__day - ) subq_25 + DATEADD(day, -2, subq_33.ds) = subq_31.metric_time__day + ) subq_34 WHERE booking__is_instant -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql index acc70ddd79..6394a8d3ac 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql @@ -1,471 +1,471 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , booking_fees - booking_fees_start_of_month AS booking_fees_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_8.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_8.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_14.booking_fees) AS booking_fees + COALESCE(subq_17.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_17.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_23.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.booking_fees_start_of_month AS booking_fees_start_of_month + subq_15.metric_time__day AS metric_time__day + , subq_14.booking_fees_start_of_month AS booking_fees_start_of_month FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_6 + subq_16.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + ) subq_15 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day + subq_13.metric_time__day , booking_value * 0.05 AS booking_fees_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.booking_value) AS booking_value + subq_11.metric_time__day + , SUM(subq_11.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 - ) subq_5 + subq_11.metric_time__day + ) subq_12 + ) subq_13 + ) subq_14 ON - DATE_TRUNC('month', subq_6.metric_time__day) = subq_5.metric_time__day - ) subq_8 + DATE_TRUNC('month', subq_15.metric_time__day) = subq_14.metric_time__day + ) subq_17 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , booking_value * 0.05 AS booking_fees FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value + subq_21.metric_time__day + , subq_21.booking_value FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_20.metric_time__day + , SUM(subq_20.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_19.metric_time__day + , subq_19.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__extract_quarter - , subq_9.ds__extract_month - , subq_9.ds__extract_day - , subq_9.ds__extract_dow - , subq_9.ds__extract_doy - , subq_9.ds_partitioned__day - , subq_9.ds_partitioned__week - , subq_9.ds_partitioned__month - , subq_9.ds_partitioned__quarter - , subq_9.ds_partitioned__year - , subq_9.ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy - , subq_9.paid_at__day - , subq_9.paid_at__week - , subq_9.paid_at__month - , subq_9.paid_at__quarter - , subq_9.paid_at__year - , subq_9.paid_at__extract_year - , subq_9.paid_at__extract_quarter - , subq_9.paid_at__extract_month - , subq_9.paid_at__extract_day - , subq_9.paid_at__extract_dow - , subq_9.paid_at__extract_doy - , subq_9.booking__ds__day - , subq_9.booking__ds__week - , subq_9.booking__ds__month - , subq_9.booking__ds__quarter - , subq_9.booking__ds__year - , subq_9.booking__ds__extract_year - , subq_9.booking__ds__extract_quarter - , subq_9.booking__ds__extract_month - , subq_9.booking__ds__extract_day - , subq_9.booking__ds__extract_dow - , subq_9.booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day - , subq_9.booking__paid_at__week - , subq_9.booking__paid_at__month - , subq_9.booking__paid_at__quarter - , subq_9.booking__paid_at__year - , subq_9.booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy - , subq_9.ds__day AS metric_time__day - , subq_9.ds__week AS metric_time__week - , subq_9.ds__month AS metric_time__month - , subq_9.ds__quarter AS metric_time__quarter - , subq_9.ds__year AS metric_time__year - , subq_9.ds__extract_year AS metric_time__extract_year - , subq_9.ds__extract_quarter AS metric_time__extract_quarter - , subq_9.ds__extract_month AS metric_time__extract_month - , subq_9.ds__extract_day AS metric_time__extract_day - , subq_9.ds__extract_dow AS metric_time__extract_dow - , subq_9.ds__extract_doy AS metric_time__extract_doy - , subq_9.listing - , subq_9.guest - , subq_9.host - , subq_9.booking__listing - , subq_9.booking__guest - , subq_9.booking__host - , subq_9.is_instant - , subq_9.booking__is_instant - , subq_9.bookings - , subq_9.instant_bookings - , subq_9.booking_value - , subq_9.max_booking_value - , subq_9.min_booking_value - , subq_9.bookers - , subq_9.average_booking_value - , subq_9.referred_bookings - , subq_9.median_booking_value - , subq_9.booking_value_p99 - , subq_9.discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 + 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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 - ) subq_10 - ) subq_11 + , 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_18 + ) subq_19 + ) subq_20 GROUP BY - subq_11.metric_time__day - ) subq_12 - ) subq_13 - ) subq_14 + subq_20.metric_time__day + ) subq_21 + ) subq_22 + ) subq_23 ON - subq_8.metric_time__day = subq_14.metric_time__day + subq_17.metric_time__day = subq_23.metric_time__day GROUP BY - COALESCE(subq_8.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_17.metric_time__day, subq_23.metric_time__day) +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql index fc648c54b6..b28105f311 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_24.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_30.booking_fees) AS booking_fees + COALESCE(subq_33.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_33.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_39.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.booking_fees_start_of_month AS booking_fees_start_of_month - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.booking_fees_start_of_month AS booking_fees_start_of_month + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,14 +28,14 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 ON - DATE_TRUNC('month', subq_23.ds) = subq_21.metric_time__day - ) subq_24 + DATE_TRUNC('month', subq_32.ds) = subq_30.metric_time__day + ) subq_33 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT @@ -50,13 +50,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_29 - ) subq_30 + ) subq_38 + ) subq_39 ON - subq_24.metric_time__day = subq_30.metric_time__day + subq_33.metric_time__day = subq_39.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_33.metric_time__day, subq_39.metric_time__day) +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0.sql index 28420deb3e..198b04fedb 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0.sql @@ -8,991 +8,991 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_30.booking_value) AS booking_value + MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.average_booking_value + subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_9.average_booking_value) AS average_booking_value + AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_8.average_booking_value + subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.booking__is_instant + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.booking__is_instant + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value 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_2.average_booking_value AS average_booking_value + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.average_booking_value + subq_10.listing + , subq_10.booking__is_instant + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_8 - ) subq_9 - ) subq_10 - ) subq_11 + ) subq_17 + ) subq_18 + ) subq_19 + ) subq_20 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.bookings + subq_31.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_21.bookings) AS bookings + SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_20.bookings + subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.booking__is_instant - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.booking__is_instant + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_18.booking__is_instant - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.listing AS listing - , subq_14.booking__is_instant AS booking__is_instant - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.listing AS listing + , subq_23.booking__is_instant AS booking__is_instant + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_13.listing - , subq_13.booking__is_instant - , subq_13.bookings + subq_22.listing + , subq_22.booking__is_instant + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_20 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_29 + ) subq_30 + ) subq_31 + ) subq_32 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_29.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_28.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_27.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 -) subq_32 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0_optimized.sql index 14649c62dd..35859d3713 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0_optimized.sql +++ b/metricflow/test/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_44.average_booking_value) AS average_booking_value - , MAX(subq_56.bookings) AS bookings - , MAX(subq_63.booking_value) AS booking_value + MAX(subq_53.average_booking_value) AS average_booking_value + , MAX(subq_65.bookings) AS bookings + , MAX(subq_72.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,17 +22,17 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - bookings_source_src_28001.is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_40 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_49 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_44 + ) subq_53 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -44,9 +44,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_47.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_47.bookings AS bookings + subq_56.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_56.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -55,15 +55,15 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_47 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_56 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_47.listing = listings_latest_src_28005.listing_id - ) subq_52 + subq_56.listing = listings_latest_src_28000.listing_id + ) subq_61 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_56 + ) subq_65 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -78,9 +78,9 @@ FROM ( SELECT is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_59 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_68 WHERE booking__is_instant - ) subq_63 - ) subq_64 -) subq_65 + ) subq_72 + ) subq_73 +) subq_74 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0.sql index ad8200aea3..d791503bb6 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0.sql @@ -1,339 +1,339 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - DATEADD(day, -2, subq_9.metric_time__day) = subq_8.metric_time__day -) subq_11 + DATEADD(day, -2, subq_18.metric_time__day) = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0_optimized.sql index e9df61ae2f..a1458a856e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -19,23 +19,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - DATEADD(day, -5, subq_15.ds) = subq_13.metric_time__day + DATEADD(day, -5, subq_24.ds) = subq_22.metric_time__day GROUP BY - subq_15.ds - ) subq_19 - ) subq_20 + subq_24.ds + ) subq_28 + ) subq_29 ON - DATEADD(day, -2, subq_22.ds) = subq_20.metric_time__day -) subq_23 + DATEADD(day, -2, subq_31.ds) = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0.sql index f269a9cada..a25fbf4807 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0.sql @@ -1,340 +1,340 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - WHERE subq_10.ds BETWEEN '2020-01-12' AND '2020-01-13' - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + WHERE subq_19.ds BETWEEN '2020-01-12' AND '2020-01-13' + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - DATEADD(day, -2, subq_9.metric_time__day) = subq_8.metric_time__day -) subq_11 + DATEADD(day, -2, subq_18.metric_time__day) = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 82beb8296d..ce05de9f1e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_21.metric_time__day AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once + subq_30.metric_time__day AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_22 + FROM ***************************.mf_time_spine subq_31 WHERE ds BETWEEN '2020-01-12' AND '2020-01-13' - ) subq_21 + ) subq_30 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -25,23 +25,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - DATEADD(day, -5, subq_15.ds) = subq_13.metric_time__day + DATEADD(day, -5, subq_24.ds) = subq_22.metric_time__day GROUP BY - subq_15.ds - ) subq_19 - ) subq_20 + subq_24.ds + ) subq_28 + ) subq_29 ON - DATEADD(day, -2, subq_21.metric_time__day) = subq_20.metric_time__day -) subq_23 + DATEADD(day, -2, subq_30.metric_time__day) = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0.sql index b77e206731..bdb9c514db 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0.sql @@ -1,346 +1,346 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day + subq_21.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - DATEADD(day, -2, subq_9.metric_time__day) = subq_8.metric_time__day - ) subq_11 + DATEADD(day, -2, subq_18.metric_time__day) = subq_17.metric_time__day + ) subq_20 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_12 +) subq_21 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0_optimized.sql index e17438d2ae..533c803d41 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -10,9 +10,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,25 +24,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.ds AS metric_time__day - , SUM(subq_14.bookings) AS bookings - FROM ***************************.mf_time_spine subq_16 + subq_25.ds AS metric_time__day + , SUM(subq_23.bookings) AS bookings + FROM ***************************.mf_time_spine subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_14 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_23 ON - DATEADD(day, -5, subq_16.ds) = subq_14.metric_time__day + DATEADD(day, -5, subq_25.ds) = subq_23.metric_time__day GROUP BY - subq_16.ds - ) subq_20 - ) subq_21 + subq_25.ds + ) subq_29 + ) subq_30 ON - DATEADD(day, -2, subq_23.ds) = subq_21.metric_time__day - ) subq_24 + DATEADD(day, -2, subq_32.ds) = subq_30.metric_time__day + ) subq_33 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_25 +) subq_34 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0.sql index 510862428a..048b3bd92d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__ds__day - ) subq_3 - ) subq_4 + subq_11.booking__ds__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.booking__ds__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.booking__ds__day) = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.booking__ds__day) = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql index 1b7dbc4725..9f6d4b5769 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.booking__ds__day + DATE_TRUNC('month', subq_31.ds) = subq_29.booking__ds__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0.sql index 1fe0aa0ce2..4780288065 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__ds__day - ) subq_3 - ) subq_4 + subq_11.booking__ds__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.booking__ds__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATEADD(day, -14, subq_7.booking__ds__day) = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + DATEADD(day, -14, subq_16.booking__ds__day) = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0_optimized.sql index 272991a8dc..dc58b2992d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATEADD(day, -14, subq_22.ds) = subq_20.booking__ds__day + DATEADD(day, -14, subq_31.ds) = subq_29.booking__ds__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0.sql index a00d889d96..fafa69dbfb 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0.sql @@ -1,320 +1,320 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - WHERE subq_3.ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + WHERE subq_12.ds BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 -) subq_7 + subq_14.metric_time__day + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0_optimized.sql index ee1dcbf475..f3a30decfa 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -8,25 +8,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago + subq_19.metric_time__day AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_20 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_10 + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - DATEADD(day, -5, subq_10.metric_time__day) = subq_9.metric_time__day + DATEADD(day, -5, subq_19.metric_time__day) = subq_18.metric_time__day GROUP BY - subq_10.metric_time__day -) subq_15 + subq_19.metric_time__day +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index bf9815e472..c9fce95365 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -1,441 +1,441 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.bookers AS every_2_days_bookers_2_days_ago + subq_19.metric_time__day + , subq_19.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , COUNT(DISTINCT subq_9.bookers) AS bookers + subq_18.metric_time__day + , COUNT(DISTINCT subq_18.bookers) AS bookers FROM ( -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] SELECT - subq_8.metric_time__day - , subq_8.bookers + subq_17.metric_time__day + , subq_17.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -2, subq_11.metric_time__day) ) - ) subq_4 + ) subq_13 ON - DATEADD(day, -2, subq_5.metric_time__day) = subq_4.metric_time__day - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_9 + DATEADD(day, -2, subq_14.metric_time__day) = subq_13.metric_time__day + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 -) subq_11 + subq_18.metric_time__day + ) subq_19 +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index d998382fb8..0f2d801995 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -9,33 +9,33 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day AS metric_time__day - , COUNT(DISTINCT subq_16.bookers) AS every_2_days_bookers_2_days_ago + subq_26.metric_time__day AS metric_time__day + , COUNT(DISTINCT subq_25.bookers) AS every_2_days_bookers_2_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_18 + FROM ***************************.mf_time_spine subq_27 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_17 + ) subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_15.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_24 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_15.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_24.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATEADD(day, -2, subq_15.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_24.ds) ) - ) subq_16 + ) subq_25 ON - DATEADD(day, -2, subq_17.metric_time__day) = subq_16.metric_time__day - WHERE subq_17.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' + DATEADD(day, -2, subq_26.metric_time__day) = subq_25.metric_time__day + WHERE subq_26.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' GROUP BY - subq_17.metric_time__day -) subq_23 + subq_26.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0.sql index dbf74a0526..ae1abe14ec 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0.sql @@ -1,445 +1,445 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_16.metric_time__day + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) -) subq_10 + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0_optimized.sql index 23f7234c6e..1638560b4d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , MAX(subq_15.ref_bookings) AS ref_bookings - , MAX(subq_20.bookings) AS bookings + COALESCE(subq_24.metric_time__day, subq_29.metric_time__day) AS metric_time__day + , MAX(subq_24.ref_bookings) AS ref_bookings + , MAX(subq_29.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,11 +21,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 GROUP BY metric_time__day - ) subq_15 + ) subq_24 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,13 +39,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_15.metric_time__day = subq_20.metric_time__day + subq_24.metric_time__day = subq_29.metric_time__day GROUP BY - COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) -) subq_21 + COALESCE(subq_24.metric_time__day, subq_29.metric_time__day) +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 72735021e2..35be63856a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -1,73 +1,73 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__month + subq_9.metric_time__month , bookings_last_month AS bookings_last_month FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly AS bookings_last_month + subq_8.metric_time__month + , subq_8.bookings_monthly AS bookings_last_month FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__month - , SUM(subq_5.bookings_monthly) AS bookings_monthly + subq_7.metric_time__month + , SUM(subq_7.bookings_monthly) AS bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_4.metric_time__month - , subq_4.bookings_monthly + subq_6.metric_time__month + , subq_6.bookings_monthly FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__month AS metric_time__month - , subq_1.monthly_ds__month AS monthly_ds__month - , subq_1.monthly_ds__quarter AS monthly_ds__quarter - , subq_1.monthly_ds__year AS monthly_ds__year - , subq_1.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_1.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_1.listing AS listing - , subq_1.booking__listing AS booking__listing - , subq_1.bookings_monthly AS bookings_monthly + subq_4.metric_time__month AS metric_time__month + , subq_3.monthly_ds__month AS monthly_ds__month + , subq_3.monthly_ds__quarter AS monthly_ds__quarter + , subq_3.monthly_ds__year AS monthly_ds__year + , subq_3.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_3.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_3.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_3.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_3.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_3.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_3.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_3.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_3.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_3.listing AS listing + , subq_3.booking__listing AS booking__listing + , subq_3.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_3.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_3 + DATE_TRUNC('month', subq_5.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_5 GROUP BY - DATE_TRUNC('month', subq_3.ds) - ) subq_2 + DATE_TRUNC('month', subq_5.ds) + ) subq_4 INNER JOIN ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_2.monthly_ds__month + , subq_2.monthly_ds__quarter + , subq_2.monthly_ds__year + , subq_2.monthly_ds__extract_year + , subq_2.monthly_ds__extract_quarter + , subq_2.monthly_ds__extract_month + , subq_2.booking__monthly_ds__month + , subq_2.booking__monthly_ds__quarter + , subq_2.booking__monthly_ds__year + , subq_2.booking__monthly_ds__extract_year + , subq_2.booking__monthly_ds__extract_quarter + , subq_2.booking__monthly_ds__extract_month + , subq_2.monthly_ds__month AS metric_time__month + , subq_2.monthly_ds__quarter AS metric_time__quarter + , subq_2.monthly_ds__year AS metric_time__year + , subq_2.monthly_ds__extract_year AS metric_time__extract_year + , subq_2.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_2.monthly_ds__extract_month AS metric_time__extract_month + , subq_2.listing + , subq_2.booking__listing + , subq_2.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -87,13 +87,13 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 + ) subq_2 + ) subq_3 ON - DATEADD(month, -1, subq_2.metric_time__month) = subq_1.metric_time__month - ) subq_4 - ) subq_5 + DATEADD(month, -1, subq_4.metric_time__month) = subq_3.metric_time__month + ) subq_6 + ) subq_7 GROUP BY - subq_5.metric_time__month - ) subq_6 -) subq_7 + subq_7.metric_time__month + ) subq_8 +) subq_9 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index ccd562cfa6..75916f38d4 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -8,20 +8,20 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month AS metric_time__month + subq_12.metric_time__month AS metric_time__month , SUM(bookings_monthly_source_src_16000.bookings_monthly) AS bookings_last_month FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_13 GROUP BY DATE_TRUNC('month', ds) - ) subq_10 + ) subq_12 INNER JOIN ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 ON - DATEADD(month, -1, subq_10.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_16000.ds) + DATEADD(month, -1, subq_12.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_16000.ds) GROUP BY - subq_10.metric_time__month -) subq_15 + subq_12.metric_time__month +) subq_17 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql index 8252ab84a8..6125565051 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__day - ) subq_11 - ) subq_12 + subq_19.metric_time__day + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) -) subq_13 + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 5138fe8ae6..2061be23cf 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day + DATE_TRUNC('month', subq_31.ds) = subq_29.metric_time__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) -) subq_27 + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index f3b7f76b55..a8f9fe0cf1 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -1,546 +1,546 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__week + subq_22.metric_time__week , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) AS metric_time__week - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__week, subq_21.metric_time__week) AS metric_time__week + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__week - , subq_3.bookings + subq_12.metric_time__week + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__week - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__week + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_1.metric_time__week - , subq_1.bookings + subq_10.metric_time__week + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__week - ) subq_3 - ) subq_4 + subq_11.metric_time__week + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__week - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__week + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__week - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__week + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_9.metric_time__week - , subq_9.bookings + subq_18.metric_time__week + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('week', subq_7.metric_time__day) AS metric_time__week - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('week', subq_16.metric_time__day) AS metric_time__week + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.metric_time__day) = subq_6.metric_time__day - WHERE DATE_TRUNC('week', subq_7.metric_time__day) = subq_7.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.metric_time__day) = subq_15.metric_time__day + WHERE DATE_TRUNC('week', subq_16.metric_time__day) = subq_16.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__week - ) subq_11 - ) subq_12 + subq_19.metric_time__week + ) subq_20 + ) subq_21 ON - subq_4.metric_time__week = subq_12.metric_time__week + subq_13.metric_time__week = subq_21.metric_time__week GROUP BY - COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) -) subq_13 + COALESCE(subq_13.metric_time__week, subq_21.metric_time__week) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index b9e4162413..65cf132abd 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) AS metric_time__week - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__week, subq_35.metric_time__week) AS metric_time__week + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,36 +21,36 @@ FROM ( SELECT DATE_TRUNC('week', ds) AS metric_time__week , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__week - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__week'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('week', subq_22.ds) AS metric_time__week - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC('week', subq_31.ds) AS metric_time__week + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day - WHERE DATE_TRUNC('week', subq_22.ds) = subq_22.ds + DATE_TRUNC('month', subq_31.ds) = subq_29.metric_time__day + WHERE DATE_TRUNC('week', subq_31.ds) = subq_31.ds GROUP BY - DATE_TRUNC('week', subq_22.ds) - ) subq_26 + DATE_TRUNC('week', subq_31.ds) + ) subq_35 ON - subq_18.metric_time__week = subq_26.metric_time__week + subq_27.metric_time__week = subq_35.metric_time__week GROUP BY - COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) -) subq_27 + COALESCE(subq_27.metric_time__week, subq_35.metric_time__week) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql index af8ee6f08a..85c04cd5d3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATEADD(day, -14, subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATEADD(day, -14, subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__day - ) subq_11 - ) subq_12 + subq_19.metric_time__day + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) -) subq_13 + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql index 197f4d5430..ba542c8a14 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_31.ds) = subq_29.metric_time__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) -) subq_27 + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql index dcaf2040bf..9f889933c5 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__quarter + subq_22.metric_time__quarter , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) AS metric_time__quarter - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__quarter, subq_21.metric_time__quarter) AS metric_time__quarter + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__quarter - , subq_3.bookings + subq_12.metric_time__quarter + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__quarter - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__quarter + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_1.metric_time__quarter - , subq_1.bookings + subq_10.metric_time__quarter + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__quarter - ) subq_3 - ) subq_4 + subq_11.metric_time__quarter + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__quarter - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__quarter + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__quarter - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__quarter + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_9.metric_time__quarter - , subq_9.bookings + subq_18.metric_time__quarter + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('quarter', subq_7.metric_time__day) AS metric_time__quarter - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('quarter', subq_16.metric_time__day) AS metric_time__quarter + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATEADD(day, -14, subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATEADD(day, -14, subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__quarter - ) subq_11 - ) subq_12 + subq_19.metric_time__quarter + ) subq_20 + ) subq_21 ON - subq_4.metric_time__quarter = subq_12.metric_time__quarter + subq_13.metric_time__quarter = subq_21.metric_time__quarter GROUP BY - COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) -) subq_13 + COALESCE(subq_13.metric_time__quarter, subq_21.metric_time__quarter) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index 89f6dcf4d2..d31ffad9a6 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) AS metric_time__quarter - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__quarter, subq_35.metric_time__quarter) AS metric_time__quarter + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('quarter', ds) AS metric_time__quarter , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__quarter - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__quarter'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('quarter', subq_22.ds) AS metric_time__quarter - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC('quarter', subq_31.ds) AS metric_time__quarter + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_31.ds) = subq_29.metric_time__day GROUP BY - DATE_TRUNC('quarter', subq_22.ds) - ) subq_26 + DATE_TRUNC('quarter', subq_31.ds) + ) subq_35 ON - subq_18.metric_time__quarter = subq_26.metric_time__quarter + subq_27.metric_time__quarter = subq_35.metric_time__quarter GROUP BY - COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) -) subq_27 + COALESCE(subq_27.metric_time__quarter, subq_35.metric_time__quarter) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index e0166aec7d..be849e6ebf 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -1,645 +1,645 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__day + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC('month', subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 + subq_14.metric_time__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATEADD(month, -1, subq_10.metric_time__day) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATEADD(month, -1, subq_19.metric_time__day) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__day - ) subq_14 - ) subq_15 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) -) subq_16 + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 1f8ce4023a..bedc1e94c6 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -5,55 +5,55 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_20.ds AS metric_time__day - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + subq_29.ds AS metric_time__day + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day + DATE_TRUNC('month', subq_29.ds) = subq_27.metric_time__day GROUP BY - subq_20.ds - ) subq_24 + subq_29.ds + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATEADD(month, -1, subq_28.ds) = subq_26.metric_time__day + DATEADD(month, -1, subq_37.ds) = subq_35.metric_time__day GROUP BY - subq_28.ds - ) subq_32 + subq_37.ds + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 69d6919302..70c5233814 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -1,646 +1,646 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__year + subq_25.metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) AS metric_time__year - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__year, subq_24.metric_time__year) AS metric_time__year + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__year - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__year + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__year - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__year + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_4.metric_time__year - , subq_4.bookings + subq_13.metric_time__year + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('year', subq_11.metric_time__day) AS metric_time__year + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - WHERE DATE_TRUNC('year', subq_2.metric_time__day) = subq_2.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC('month', subq_11.metric_time__day) = subq_10.metric_time__day + WHERE DATE_TRUNC('year', subq_11.metric_time__day) = subq_11.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__year - ) subq_6 - ) subq_7 + subq_14.metric_time__year + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__year - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__year + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__year - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__year + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_12.metric_time__year - , subq_12.bookings + subq_21.metric_time__year + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_10.metric_time__day) AS metric_time__year - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('year', subq_19.metric_time__day) AS metric_time__year + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATEADD(month, -1, subq_10.metric_time__day) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATEADD(month, -1, subq_19.metric_time__day) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__year - ) subq_14 - ) subq_15 + subq_22.metric_time__year + ) subq_23 + ) subq_24 ON - subq_7.metric_time__year = subq_15.metric_time__year + subq_16.metric_time__year = subq_24.metric_time__year GROUP BY - COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) -) subq_16 + COALESCE(subq_16.metric_time__year, subq_24.metric_time__year) +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 6df1bd72d2..3b62cf5d4b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,56 +5,56 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) AS metric_time__year - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__year, subq_41.metric_time__year) AS metric_time__year + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_20.ds) AS metric_time__year - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + DATE_TRUNC('year', subq_29.ds) AS metric_time__year + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day - WHERE DATE_TRUNC('year', subq_20.ds) = subq_20.ds + DATE_TRUNC('month', subq_29.ds) = subq_27.metric_time__day + WHERE DATE_TRUNC('year', subq_29.ds) = subq_29.ds GROUP BY - DATE_TRUNC('year', subq_20.ds) - ) subq_24 + DATE_TRUNC('year', subq_29.ds) + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_28.ds) AS metric_time__year - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + DATE_TRUNC('year', subq_37.ds) AS metric_time__year + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATEADD(month, -1, subq_28.ds) = subq_26.metric_time__day + DATEADD(month, -1, subq_37.ds) = subq_35.metric_time__day GROUP BY - DATE_TRUNC('year', subq_28.ds) - ) subq_32 + DATE_TRUNC('year', subq_37.ds) + ) subq_41 ON - subq_24.metric_time__year = subq_32.metric_time__year + subq_33.metric_time__year = subq_41.metric_time__year GROUP BY - COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) -) subq_33 + COALESCE(subq_33.metric_time__year, subq_41.metric_time__year) +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index c1c21d252e..306a0e839d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_5.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_5.bookings) AS bookings - , MAX(subq_14.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_14.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_14.bookings) AS bookings + , MAX(subq_23.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_3.metric_time__day - , SUM(subq_3.bookings) AS bookings + subq_12.metric_time__day + , SUM(subq_12.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.bookings + subq_11.metric_time__day + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_3 + ) subq_12 GROUP BY - subq_3.metric_time__day - ) subq_4 - ) subq_5 + subq_12.metric_time__day + ) subq_13 + ) subq_14 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.bookings AS bookings_2_weeks_ago + subq_22.metric_time__day + , subq_22.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.bookings) AS bookings + subq_21.metric_time__day + , SUM(subq_21.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings + subq_20.metric_time__day + , subq_20.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_19.metric_time__day + , subq_19.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.ds__day AS ds__day - , subq_7.ds__week AS ds__week - , subq_7.ds__month AS ds__month - , subq_7.ds__quarter AS ds__quarter - , subq_7.ds__year AS ds__year - , subq_7.ds__extract_year AS ds__extract_year - , subq_7.ds__extract_quarter AS ds__extract_quarter - , subq_7.ds__extract_month AS ds__extract_month - , subq_7.ds__extract_day AS ds__extract_day - , subq_7.ds__extract_dow AS ds__extract_dow - , subq_7.ds__extract_doy AS ds__extract_doy - , subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__week AS ds_partitioned__week - , subq_7.ds_partitioned__month AS ds_partitioned__month - , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_7.ds_partitioned__year AS ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_7.paid_at__day AS paid_at__day - , subq_7.paid_at__week AS paid_at__week - , subq_7.paid_at__month AS paid_at__month - , subq_7.paid_at__quarter AS paid_at__quarter - , subq_7.paid_at__year AS paid_at__year - , subq_7.paid_at__extract_year AS paid_at__extract_year - , subq_7.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_7.paid_at__extract_month AS paid_at__extract_month - , subq_7.paid_at__extract_day AS paid_at__extract_day - , subq_7.paid_at__extract_dow AS paid_at__extract_dow - , subq_7.paid_at__extract_doy AS paid_at__extract_doy - , subq_7.booking__ds__day AS booking__ds__day - , subq_7.booking__ds__week AS booking__ds__week - , subq_7.booking__ds__month AS booking__ds__month - , subq_7.booking__ds__quarter AS booking__ds__quarter - , subq_7.booking__ds__year AS booking__ds__year - , subq_7.booking__ds__extract_year AS booking__ds__extract_year - , subq_7.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_7.booking__ds__extract_month AS booking__ds__extract_month - , subq_7.booking__ds__extract_day AS booking__ds__extract_day - , subq_7.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_7.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day AS booking__paid_at__day - , subq_7.booking__paid_at__week AS booking__paid_at__week - , subq_7.booking__paid_at__month AS booking__paid_at__month - , subq_7.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_7.booking__paid_at__year AS booking__paid_at__year - , subq_7.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_7.listing AS listing - , subq_7.guest AS guest - , subq_7.host AS host - , subq_7.booking__listing AS booking__listing - , subq_7.booking__guest AS booking__guest - , subq_7.booking__host AS booking__host - , subq_7.is_instant AS is_instant - , subq_7.booking__is_instant AS booking__is_instant - , subq_7.bookings AS bookings - , subq_7.instant_bookings AS instant_bookings - , subq_7.booking_value AS booking_value - , subq_7.max_booking_value AS max_booking_value - , subq_7.min_booking_value AS min_booking_value - , subq_7.bookers AS bookers - , subq_7.average_booking_value AS average_booking_value - , subq_7.referred_bookings AS referred_bookings - , subq_7.median_booking_value AS median_booking_value - , subq_7.booking_value_p99 AS booking_value_p99 - , subq_7.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_17.metric_time__day AS metric_time__day + , subq_16.ds__day AS ds__day + , subq_16.ds__week AS ds__week + , subq_16.ds__month AS ds__month + , subq_16.ds__quarter AS ds__quarter + , subq_16.ds__year AS ds__year + , subq_16.ds__extract_year AS ds__extract_year + , subq_16.ds__extract_quarter AS ds__extract_quarter + , subq_16.ds__extract_month AS ds__extract_month + , subq_16.ds__extract_day AS ds__extract_day + , subq_16.ds__extract_dow AS ds__extract_dow + , subq_16.ds__extract_doy AS ds__extract_doy + , subq_16.ds_partitioned__day AS ds_partitioned__day + , subq_16.ds_partitioned__week AS ds_partitioned__week + , subq_16.ds_partitioned__month AS ds_partitioned__month + , subq_16.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_16.ds_partitioned__year AS ds_partitioned__year + , subq_16.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_16.paid_at__day AS paid_at__day + , subq_16.paid_at__week AS paid_at__week + , subq_16.paid_at__month AS paid_at__month + , subq_16.paid_at__quarter AS paid_at__quarter + , subq_16.paid_at__year AS paid_at__year + , subq_16.paid_at__extract_year AS paid_at__extract_year + , subq_16.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_16.paid_at__extract_month AS paid_at__extract_month + , subq_16.paid_at__extract_day AS paid_at__extract_day + , subq_16.paid_at__extract_dow AS paid_at__extract_dow + , subq_16.paid_at__extract_doy AS paid_at__extract_doy + , subq_16.booking__ds__day AS booking__ds__day + , subq_16.booking__ds__week AS booking__ds__week + , subq_16.booking__ds__month AS booking__ds__month + , subq_16.booking__ds__quarter AS booking__ds__quarter + , subq_16.booking__ds__year AS booking__ds__year + , subq_16.booking__ds__extract_year AS booking__ds__extract_year + , subq_16.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_16.booking__ds__extract_month AS booking__ds__extract_month + , subq_16.booking__ds__extract_day AS booking__ds__extract_day + , subq_16.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_16.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day AS booking__paid_at__day + , subq_16.booking__paid_at__week AS booking__paid_at__week + , subq_16.booking__paid_at__month AS booking__paid_at__month + , subq_16.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_16.booking__paid_at__year AS booking__paid_at__year + , subq_16.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_16.listing AS listing + , subq_16.guest AS guest + , subq_16.host AS host + , subq_16.booking__listing AS booking__listing + , subq_16.booking__guest AS booking__guest + , subq_16.booking__host AS booking__host + , subq_16.is_instant AS is_instant + , subq_16.booking__is_instant AS booking__is_instant + , subq_16.bookings AS bookings + , subq_16.instant_bookings AS instant_bookings + , subq_16.booking_value AS booking_value + , subq_16.max_booking_value AS max_booking_value + , subq_16.min_booking_value AS min_booking_value + , subq_16.bookers AS bookers + , subq_16.average_booking_value AS average_booking_value + , subq_16.referred_bookings AS referred_bookings + , subq_16.median_booking_value AS median_booking_value + , subq_16.booking_value_p99 AS booking_value_p99 + , subq_16.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_16.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - ) subq_8 + subq_18.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + ) subq_17 INNER JOIN ( -- 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_15.ds__day + , subq_15.ds__week + , subq_15.ds__month + , subq_15.ds__quarter + , subq_15.ds__year + , subq_15.ds__extract_year + , subq_15.ds__extract_quarter + , subq_15.ds__extract_month + , subq_15.ds__extract_day + , subq_15.ds__extract_dow + , subq_15.ds__extract_doy + , subq_15.ds_partitioned__day + , subq_15.ds_partitioned__week + , subq_15.ds_partitioned__month + , subq_15.ds_partitioned__quarter + , subq_15.ds_partitioned__year + , subq_15.ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy + , subq_15.paid_at__day + , subq_15.paid_at__week + , subq_15.paid_at__month + , subq_15.paid_at__quarter + , subq_15.paid_at__year + , subq_15.paid_at__extract_year + , subq_15.paid_at__extract_quarter + , subq_15.paid_at__extract_month + , subq_15.paid_at__extract_day + , subq_15.paid_at__extract_dow + , subq_15.paid_at__extract_doy + , subq_15.booking__ds__day + , subq_15.booking__ds__week + , subq_15.booking__ds__month + , subq_15.booking__ds__quarter + , subq_15.booking__ds__year + , subq_15.booking__ds__extract_year + , subq_15.booking__ds__extract_quarter + , subq_15.booking__ds__extract_month + , subq_15.booking__ds__extract_day + , subq_15.booking__ds__extract_dow + , subq_15.booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day + , subq_15.booking__paid_at__week + , subq_15.booking__paid_at__month + , subq_15.booking__paid_at__quarter + , subq_15.booking__paid_at__year + , subq_15.booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy + , subq_15.ds__day AS metric_time__day + , subq_15.ds__week AS metric_time__week + , subq_15.ds__month AS metric_time__month + , subq_15.ds__quarter AS metric_time__quarter + , subq_15.ds__year AS metric_time__year + , subq_15.ds__extract_year AS metric_time__extract_year + , subq_15.ds__extract_quarter AS metric_time__extract_quarter + , subq_15.ds__extract_month AS metric_time__extract_month + , subq_15.ds__extract_day AS metric_time__extract_day + , subq_15.ds__extract_dow AS metric_time__extract_dow + , subq_15.ds__extract_doy AS metric_time__extract_doy + , subq_15.listing + , subq_15.guest + , subq_15.host + , subq_15.booking__listing + , subq_15.booking__guest + , subq_15.booking__host + , subq_15.is_instant + , subq_15.booking__is_instant + , subq_15.bookings + , subq_15.instant_bookings + , subq_15.booking_value + , subq_15.max_booking_value + , subq_15.min_booking_value + , subq_15.bookers + , subq_15.average_booking_value + , subq_15.referred_bookings + , subq_15.median_booking_value + , subq_15.booking_value_p99 + , subq_15.discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 + , subq_15.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 - ) subq_7 + , 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_15 + ) subq_16 ON - DATEADD(day, -14, subq_8.metric_time__day) = subq_7.metric_time__day - ) subq_10 - ) subq_11 + DATEADD(day, -14, subq_17.metric_time__day) = subq_16.metric_time__day + ) subq_19 + ) subq_20 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_12 + ) subq_21 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_21.metric_time__day + ) subq_22 + ) subq_23 ON - subq_5.metric_time__day = subq_14.metric_time__day + subq_14.metric_time__day = subq_23.metric_time__day GROUP BY - COALESCE(subq_5.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_14.metric_time__day, subq_23.metric_time__day) +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 526089b4ce..e4dc96227a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_21.bookings) AS bookings - , MAX(subq_30.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_30.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_30.bookings) AS bookings + , MAX(subq_39.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -22,12 +22,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_21 + ) subq_30 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -39,26 +39,26 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_25.ds AS metric_time__day - , subq_23.bookings AS bookings - FROM ***************************.mf_time_spine subq_25 + subq_34.ds AS metric_time__day + , subq_32.bookings AS bookings + FROM ***************************.mf_time_spine subq_34 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 ON - DATEADD(day, -14, subq_25.ds) = subq_23.metric_time__day - ) subq_27 + DATEADD(day, -14, subq_34.ds) = subq_32.metric_time__day + ) subq_36 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_30 + ) subq_39 ON - subq_21.metric_time__day = subq_30.metric_time__day + subq_30.metric_time__day = subq_39.metric_time__day GROUP BY - COALESCE(subq_21.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_30.metric_time__day, subq_39.metric_time__day) +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql index f3f1612e00..3baf50f20d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql @@ -1,433 +1,433 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookers AS every_2_days_bookers_2_days_ago + subq_18.metric_time__day + , subq_18.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , COUNT(DISTINCT subq_8.bookers) AS bookers + subq_17.metric_time__day + , COUNT(DISTINCT subq_17.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -2, subq_11.metric_time__day) ) - ) subq_4 + ) subq_13 ON - DATEADD(day, -2, subq_5.metric_time__day) = subq_4.metric_time__day - ) subq_7 - ) subq_8 + DATEADD(day, -2, subq_14.metric_time__day) = subq_13.metric_time__day + ) subq_16 + ) subq_17 GROUP BY - subq_8.metric_time__day - ) subq_9 -) subq_10 + subq_17.metric_time__day + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0_optimized.sql index 866ba0a41b..d5e3a9771e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -8,26 +8,26 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , COUNT(DISTINCT subq_15.bookers) AS every_2_days_bookers_2_days_ago - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , COUNT(DISTINCT subq_24.bookers) AS every_2_days_bookers_2_days_ago + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_14.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_14 + subq_23.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_23 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_23.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATEADD(day, -2, subq_14.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_23.ds) ) - ) subq_15 + ) subq_24 ON - DATEADD(day, -2, subq_17.ds) = subq_15.metric_time__day + DATEADD(day, -2, subq_26.ds) = subq_24.metric_time__day GROUP BY - subq_17.ds -) subq_21 + subq_26.ds +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0.sql index 335341b000..1c44ebb3ce 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_7.booking_value) AS booking_value - , MAX(subq_12.bookers) AS bookers + COALESCE(subq_16.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_16.booking_value) AS booking_value + , MAX(subq_21.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_6.booking__ds__day - , subq_6.booking_value + subq_15.booking__ds__day + , subq_15.booking_value FROM ( -- Aggregate Measures SELECT - subq_5.booking__ds__day - , SUM(subq_5.booking_value) AS booking_value + subq_14.booking__ds__day + , SUM(subq_14.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__ds__day'] SELECT - subq_4.booking__ds__day - , subq_4.booking_value + subq_13.booking__ds__day + , subq_13.booking_value FROM ( -- Join to Time Spine Dataset SELECT - subq_2.booking__ds__day AS booking__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.booking__ds__day AS booking__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(week, -1, subq_2.booking__ds__day) = subq_1.booking__ds__day - ) subq_4 - ) subq_5 + DATEADD(week, -1, subq_11.booking__ds__day) = subq_10.booking__ds__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.booking__ds__day - ) subq_6 - ) subq_7 + subq_14.booking__ds__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookers + subq_20.booking__ds__day + , subq_20.bookers FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , COUNT(DISTINCT subq_10.bookers) AS bookers + subq_19.booking__ds__day + , COUNT(DISTINCT subq_19.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookers + subq_18.booking__ds__day + , subq_18.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 - ) subq_10 + , 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_17 + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_7.booking__ds__day = subq_12.booking__ds__day + subq_16.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_7.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_16.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql index 085c58e4f4..0edb7a0c7b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql @@ -5,25 +5,25 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_21.booking_value) AS booking_value - , MAX(subq_26.bookers) AS bookers + COALESCE(subq_30.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_30.booking_value) AS booking_value + , MAX(subq_35.bookers) AS bookers FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['booking_value', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS booking__ds__day - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS booking__ds__day + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.mf_time_spine subq_26 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_17.ds) = DATE_TRUNC('day', bookings_source_src_28001.ds) + DATEADD(week, -1, subq_26.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds - ) subq_21 + subq_26.ds + ) subq_30 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -33,12 +33,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , COUNT(DISTINCT guest_id) AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_26 + ) subq_35 ON - subq_21.booking__ds__day = subq_26.booking__ds__day + subq_30.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_21.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_30.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql index 1cab837f78..bfaca9325c 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -1,319 +1,319 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 -) subq_7 + subq_14.metric_time__day + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 56f1d26f59..1a6402a3bb 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -8,19 +8,19 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago + FROM ***************************.mf_time_spine subq_20 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - DATEADD(day, -5, subq_11.ds) = subq_9.metric_time__day + DATEADD(day, -5, subq_20.ds) = subq_18.metric_time__day GROUP BY - subq_11.ds -) subq_15 + subq_20.ds +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0.sql index a172445bdd..d09aef456d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0.sql @@ -1,895 +1,895 @@ -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day + subq_31.metric_time__day , non_referred + (instant * 1.0 / bookings) AS instant_plus_non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) AS metric_time__day - , MAX(subq_11.non_referred) AS non_referred - , MAX(subq_16.instant) AS instant - , MAX(subq_21.bookings) AS bookings + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day + , MAX(subq_20.non_referred) AS non_referred + , MAX(subq_25.instant) AS instant + , MAX(subq_30.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_16.metric_time__day + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) - ) subq_10 - ) subq_11 + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day - , subq_15.instant_bookings AS instant + subq_24.metric_time__day + , subq_24.instant_bookings AS instant FROM ( -- Aggregate Measures SELECT - subq_14.metric_time__day - , SUM(subq_14.instant_bookings) AS instant_bookings + subq_23.metric_time__day + , SUM(subq_23.instant_bookings) AS instant_bookings FROM ( -- Pass Only Elements: ['instant_bookings', 'metric_time__day'] SELECT - subq_13.metric_time__day - , subq_13.instant_bookings + subq_22.metric_time__day + , subq_22.instant_bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 GROUP BY - subq_14.metric_time__day - ) subq_15 - ) subq_16 + subq_23.metric_time__day + ) subq_24 + ) subq_25 ON - subq_11.metric_time__day = subq_16.metric_time__day + subq_20.metric_time__day = subq_25.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Aggregate Measures SELECT - subq_19.metric_time__day - , SUM(subq_19.bookings) AS bookings + subq_28.metric_time__day + , SUM(subq_28.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.bookings + subq_27.metric_time__day + , subq_27.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_17.ds__day - , subq_17.ds__week - , subq_17.ds__month - , subq_17.ds__quarter - , subq_17.ds__year - , subq_17.ds__extract_year - , subq_17.ds__extract_quarter - , subq_17.ds__extract_month - , subq_17.ds__extract_day - , subq_17.ds__extract_dow - , subq_17.ds__extract_doy - , subq_17.ds_partitioned__day - , subq_17.ds_partitioned__week - , subq_17.ds_partitioned__month - , subq_17.ds_partitioned__quarter - , subq_17.ds_partitioned__year - , subq_17.ds_partitioned__extract_year - , subq_17.ds_partitioned__extract_quarter - , subq_17.ds_partitioned__extract_month - , subq_17.ds_partitioned__extract_day - , subq_17.ds_partitioned__extract_dow - , subq_17.ds_partitioned__extract_doy - , subq_17.paid_at__day - , subq_17.paid_at__week - , subq_17.paid_at__month - , subq_17.paid_at__quarter - , subq_17.paid_at__year - , subq_17.paid_at__extract_year - , subq_17.paid_at__extract_quarter - , subq_17.paid_at__extract_month - , subq_17.paid_at__extract_day - , subq_17.paid_at__extract_dow - , subq_17.paid_at__extract_doy - , subq_17.booking__ds__day - , subq_17.booking__ds__week - , subq_17.booking__ds__month - , subq_17.booking__ds__quarter - , subq_17.booking__ds__year - , subq_17.booking__ds__extract_year - , subq_17.booking__ds__extract_quarter - , subq_17.booking__ds__extract_month - , subq_17.booking__ds__extract_day - , subq_17.booking__ds__extract_dow - , subq_17.booking__ds__extract_doy - , subq_17.booking__ds_partitioned__day - , subq_17.booking__ds_partitioned__week - , subq_17.booking__ds_partitioned__month - , subq_17.booking__ds_partitioned__quarter - , subq_17.booking__ds_partitioned__year - , subq_17.booking__ds_partitioned__extract_year - , subq_17.booking__ds_partitioned__extract_quarter - , subq_17.booking__ds_partitioned__extract_month - , subq_17.booking__ds_partitioned__extract_day - , subq_17.booking__ds_partitioned__extract_dow - , subq_17.booking__ds_partitioned__extract_doy - , subq_17.booking__paid_at__day - , subq_17.booking__paid_at__week - , subq_17.booking__paid_at__month - , subq_17.booking__paid_at__quarter - , subq_17.booking__paid_at__year - , subq_17.booking__paid_at__extract_year - , subq_17.booking__paid_at__extract_quarter - , subq_17.booking__paid_at__extract_month - , subq_17.booking__paid_at__extract_day - , subq_17.booking__paid_at__extract_dow - , subq_17.booking__paid_at__extract_doy - , subq_17.ds__day AS metric_time__day - , subq_17.ds__week AS metric_time__week - , subq_17.ds__month AS metric_time__month - , subq_17.ds__quarter AS metric_time__quarter - , subq_17.ds__year AS metric_time__year - , subq_17.ds__extract_year AS metric_time__extract_year - , subq_17.ds__extract_quarter AS metric_time__extract_quarter - , subq_17.ds__extract_month AS metric_time__extract_month - , subq_17.ds__extract_day AS metric_time__extract_day - , subq_17.ds__extract_dow AS metric_time__extract_dow - , subq_17.ds__extract_doy AS metric_time__extract_doy - , subq_17.listing - , subq_17.guest - , subq_17.host - , subq_17.booking__listing - , subq_17.booking__guest - , subq_17.booking__host - , subq_17.is_instant - , subq_17.booking__is_instant - , subq_17.bookings - , subq_17.instant_bookings - , subq_17.booking_value - , subq_17.max_booking_value - , subq_17.min_booking_value - , subq_17.bookers - , subq_17.average_booking_value - , subq_17.referred_bookings - , subq_17.median_booking_value - , subq_17.booking_value_p99 - , subq_17.discrete_booking_value_p99 - , subq_17.approximate_continuous_booking_value_p99 - , subq_17.approximate_discrete_booking_value_p99 + subq_26.ds__day + , subq_26.ds__week + , subq_26.ds__month + , subq_26.ds__quarter + , subq_26.ds__year + , subq_26.ds__extract_year + , subq_26.ds__extract_quarter + , subq_26.ds__extract_month + , subq_26.ds__extract_day + , subq_26.ds__extract_dow + , subq_26.ds__extract_doy + , subq_26.ds_partitioned__day + , subq_26.ds_partitioned__week + , subq_26.ds_partitioned__month + , subq_26.ds_partitioned__quarter + , subq_26.ds_partitioned__year + , subq_26.ds_partitioned__extract_year + , subq_26.ds_partitioned__extract_quarter + , subq_26.ds_partitioned__extract_month + , subq_26.ds_partitioned__extract_day + , subq_26.ds_partitioned__extract_dow + , subq_26.ds_partitioned__extract_doy + , subq_26.paid_at__day + , subq_26.paid_at__week + , subq_26.paid_at__month + , subq_26.paid_at__quarter + , subq_26.paid_at__year + , subq_26.paid_at__extract_year + , subq_26.paid_at__extract_quarter + , subq_26.paid_at__extract_month + , subq_26.paid_at__extract_day + , subq_26.paid_at__extract_dow + , subq_26.paid_at__extract_doy + , subq_26.booking__ds__day + , subq_26.booking__ds__week + , subq_26.booking__ds__month + , subq_26.booking__ds__quarter + , subq_26.booking__ds__year + , subq_26.booking__ds__extract_year + , subq_26.booking__ds__extract_quarter + , subq_26.booking__ds__extract_month + , subq_26.booking__ds__extract_day + , subq_26.booking__ds__extract_dow + , subq_26.booking__ds__extract_doy + , subq_26.booking__ds_partitioned__day + , subq_26.booking__ds_partitioned__week + , subq_26.booking__ds_partitioned__month + , subq_26.booking__ds_partitioned__quarter + , subq_26.booking__ds_partitioned__year + , subq_26.booking__ds_partitioned__extract_year + , subq_26.booking__ds_partitioned__extract_quarter + , subq_26.booking__ds_partitioned__extract_month + , subq_26.booking__ds_partitioned__extract_day + , subq_26.booking__ds_partitioned__extract_dow + , subq_26.booking__ds_partitioned__extract_doy + , subq_26.booking__paid_at__day + , subq_26.booking__paid_at__week + , subq_26.booking__paid_at__month + , subq_26.booking__paid_at__quarter + , subq_26.booking__paid_at__year + , subq_26.booking__paid_at__extract_year + , subq_26.booking__paid_at__extract_quarter + , subq_26.booking__paid_at__extract_month + , subq_26.booking__paid_at__extract_day + , subq_26.booking__paid_at__extract_dow + , subq_26.booking__paid_at__extract_doy + , subq_26.ds__day AS metric_time__day + , subq_26.ds__week AS metric_time__week + , subq_26.ds__month AS metric_time__month + , subq_26.ds__quarter AS metric_time__quarter + , subq_26.ds__year AS metric_time__year + , subq_26.ds__extract_year AS metric_time__extract_year + , subq_26.ds__extract_quarter AS metric_time__extract_quarter + , subq_26.ds__extract_month AS metric_time__extract_month + , subq_26.ds__extract_day AS metric_time__extract_day + , subq_26.ds__extract_dow AS metric_time__extract_dow + , subq_26.ds__extract_doy AS metric_time__extract_doy + , subq_26.listing + , subq_26.guest + , subq_26.host + , subq_26.booking__listing + , subq_26.booking__guest + , subq_26.booking__host + , subq_26.is_instant + , subq_26.booking__is_instant + , subq_26.bookings + , subq_26.instant_bookings + , subq_26.booking_value + , subq_26.max_booking_value + , subq_26.min_booking_value + , subq_26.bookers + , subq_26.average_booking_value + , subq_26.referred_bookings + , subq_26.median_booking_value + , subq_26.booking_value_p99 + , subq_26.discrete_booking_value_p99 + , subq_26.approximate_continuous_booking_value_p99 + , subq_26.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_17 - ) subq_18 - ) subq_19 + , 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_26 + ) subq_27 + ) subq_28 GROUP BY - subq_19.metric_time__day - ) subq_20 - ) subq_21 + subq_28.metric_time__day + ) subq_29 + ) subq_30 ON - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day) = subq_21.metric_time__day + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day) = subq_30.metric_time__day GROUP BY - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) -) subq_22 + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day, subq_30.metric_time__day) +) subq_31 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0_optimized.sql index 78837fdd96..da1e9fdd5a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) AS metric_time__day - , MAX(subq_34.non_referred) AS non_referred - , MAX(subq_39.instant) AS instant - , MAX(subq_44.bookings) AS bookings + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day, subq_53.metric_time__day) AS metric_time__day + , MAX(subq_43.non_referred) AS non_referred + , MAX(subq_48.instant) AS instant + , MAX(subq_53.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -17,9 +17,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.ref_bookings) AS ref_bookings - , MAX(subq_32.bookings) AS bookings + COALESCE(subq_36.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_36.ref_bookings) AS ref_bookings + , MAX(subq_41.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -33,11 +33,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_25 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_34 GROUP BY metric_time__day - ) subq_27 + ) subq_36 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -51,17 +51,17 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_30 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_39 GROUP BY metric_time__day - ) subq_32 + ) subq_41 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_36.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) - ) subq_33 - ) subq_34 + COALESCE(subq_36.metric_time__day, subq_41.metric_time__day) + ) subq_42 + ) subq_43 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -75,13 +75,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_37 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_46 GROUP BY metric_time__day - ) subq_39 + ) subq_48 ON - subq_34.metric_time__day = subq_39.metric_time__day + subq_43.metric_time__day = subq_48.metric_time__day FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -95,13 +95,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_42 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_51 GROUP BY metric_time__day - ) subq_44 + ) subq_53 ON - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day) = subq_44.metric_time__day + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day) = subq_53.metric_time__day GROUP BY - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) -) subq_45 + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day, subq_53.metric_time__day) +) subq_54 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index fd8311f18a..9eb233f224 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -1,359 +1,359 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Pass Only Elements: ['metric_time__day', 'bookings_offset_once'] SELECT - subq_12.metric_time__day - , subq_12.bookings_offset_once + subq_21.metric_time__day + , subq_21.bookings_offset_once FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.booking__is_instant - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.booking__is_instant + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.booking__is_instant AS booking__is_instant - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.booking__is_instant AS booking__is_instant + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant + subq_16.metric_time__day + , subq_16.booking__is_instant , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.bookings + subq_15.metric_time__day + , subq_15.booking__is_instant + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , subq_14.booking__is_instant + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_13.metric_time__day + , subq_13.booking__is_instant + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - , subq_5.booking__is_instant - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + , subq_14.booking__is_instant + ) subq_15 + ) subq_16 + ) subq_17 ON - DATEADD(day, -2, subq_9.metric_time__day) = subq_8.metric_time__day - ) subq_11 + DATEADD(day, -2, subq_18.metric_time__day) = subq_17.metric_time__day + ) subq_20 WHERE booking__is_instant - ) subq_12 -) subq_13 + ) subq_21 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index 611927c9a2..558939c098 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -11,10 +11,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_24.ds AS metric_time__day - , subq_22.booking__is_instant AS booking__is_instant - , subq_22.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_24 + subq_33.ds AS metric_time__day + , subq_31.booking__is_instant AS booking__is_instant + , subq_31.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_33 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -27,10 +27,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , subq_15.booking__is_instant AS booking__is_instant - , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , subq_24.booking__is_instant AS booking__is_instant + , SUM(subq_24.bookings) AS bookings + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -38,17 +38,17 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 ON - DATEADD(day, -5, subq_17.ds) = subq_15.metric_time__day + DATEADD(day, -5, subq_26.ds) = subq_24.metric_time__day GROUP BY - subq_17.ds - , subq_15.booking__is_instant - ) subq_21 - ) subq_22 + subq_26.ds + , subq_24.booking__is_instant + ) subq_30 + ) subq_31 ON - DATEADD(day, -2, subq_24.ds) = subq_22.metric_time__day - ) subq_25 + DATEADD(day, -2, subq_33.ds) = subq_31.metric_time__day + ) subq_34 WHERE booking__is_instant -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql index 975ec9ee9c..46d0d80919 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql @@ -1,471 +1,471 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , booking_fees - booking_fees_start_of_month AS booking_fees_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_8.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_8.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_14.booking_fees) AS booking_fees + COALESCE(subq_17.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_17.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_23.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.booking_fees_start_of_month AS booking_fees_start_of_month + subq_15.metric_time__day AS metric_time__day + , subq_14.booking_fees_start_of_month AS booking_fees_start_of_month FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_6 + subq_16.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + ) subq_15 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day + subq_13.metric_time__day , booking_value * 0.05 AS booking_fees_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.booking_value) AS booking_value + subq_11.metric_time__day + , SUM(subq_11.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 - ) subq_5 + subq_11.metric_time__day + ) subq_12 + ) subq_13 + ) subq_14 ON - DATE_TRUNC('month', subq_6.metric_time__day) = subq_5.metric_time__day - ) subq_8 + DATE_TRUNC('month', subq_15.metric_time__day) = subq_14.metric_time__day + ) subq_17 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , booking_value * 0.05 AS booking_fees FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value + subq_21.metric_time__day + , subq_21.booking_value FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_20.metric_time__day + , SUM(subq_20.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_19.metric_time__day + , subq_19.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__extract_quarter - , subq_9.ds__extract_month - , subq_9.ds__extract_day - , subq_9.ds__extract_dow - , subq_9.ds__extract_doy - , subq_9.ds_partitioned__day - , subq_9.ds_partitioned__week - , subq_9.ds_partitioned__month - , subq_9.ds_partitioned__quarter - , subq_9.ds_partitioned__year - , subq_9.ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy - , subq_9.paid_at__day - , subq_9.paid_at__week - , subq_9.paid_at__month - , subq_9.paid_at__quarter - , subq_9.paid_at__year - , subq_9.paid_at__extract_year - , subq_9.paid_at__extract_quarter - , subq_9.paid_at__extract_month - , subq_9.paid_at__extract_day - , subq_9.paid_at__extract_dow - , subq_9.paid_at__extract_doy - , subq_9.booking__ds__day - , subq_9.booking__ds__week - , subq_9.booking__ds__month - , subq_9.booking__ds__quarter - , subq_9.booking__ds__year - , subq_9.booking__ds__extract_year - , subq_9.booking__ds__extract_quarter - , subq_9.booking__ds__extract_month - , subq_9.booking__ds__extract_day - , subq_9.booking__ds__extract_dow - , subq_9.booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day - , subq_9.booking__paid_at__week - , subq_9.booking__paid_at__month - , subq_9.booking__paid_at__quarter - , subq_9.booking__paid_at__year - , subq_9.booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy - , subq_9.ds__day AS metric_time__day - , subq_9.ds__week AS metric_time__week - , subq_9.ds__month AS metric_time__month - , subq_9.ds__quarter AS metric_time__quarter - , subq_9.ds__year AS metric_time__year - , subq_9.ds__extract_year AS metric_time__extract_year - , subq_9.ds__extract_quarter AS metric_time__extract_quarter - , subq_9.ds__extract_month AS metric_time__extract_month - , subq_9.ds__extract_day AS metric_time__extract_day - , subq_9.ds__extract_dow AS metric_time__extract_dow - , subq_9.ds__extract_doy AS metric_time__extract_doy - , subq_9.listing - , subq_9.guest - , subq_9.host - , subq_9.booking__listing - , subq_9.booking__guest - , subq_9.booking__host - , subq_9.is_instant - , subq_9.booking__is_instant - , subq_9.bookings - , subq_9.instant_bookings - , subq_9.booking_value - , subq_9.max_booking_value - , subq_9.min_booking_value - , subq_9.bookers - , subq_9.average_booking_value - , subq_9.referred_bookings - , subq_9.median_booking_value - , subq_9.booking_value_p99 - , subq_9.discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 + 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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 - ) subq_10 - ) subq_11 + , 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_18 + ) subq_19 + ) subq_20 GROUP BY - subq_11.metric_time__day - ) subq_12 - ) subq_13 - ) subq_14 + subq_20.metric_time__day + ) subq_21 + ) subq_22 + ) subq_23 ON - subq_8.metric_time__day = subq_14.metric_time__day + subq_17.metric_time__day = subq_23.metric_time__day GROUP BY - COALESCE(subq_8.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_17.metric_time__day, subq_23.metric_time__day) +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql index fc648c54b6..b28105f311 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_24.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_30.booking_fees) AS booking_fees + COALESCE(subq_33.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_33.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_39.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.booking_fees_start_of_month AS booking_fees_start_of_month - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.booking_fees_start_of_month AS booking_fees_start_of_month + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,14 +28,14 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 ON - DATE_TRUNC('month', subq_23.ds) = subq_21.metric_time__day - ) subq_24 + DATE_TRUNC('month', subq_32.ds) = subq_30.metric_time__day + ) subq_33 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT @@ -50,13 +50,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_29 - ) subq_30 + ) subq_38 + ) subq_39 ON - subq_24.metric_time__day = subq_30.metric_time__day + subq_33.metric_time__day = subq_39.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_33.metric_time__day, subq_39.metric_time__day) +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0.sql index fd0cd1a4ff..01e0578ea4 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0.sql @@ -8,991 +8,991 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_30.booking_value) AS booking_value + MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.average_booking_value + subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_9.average_booking_value) AS average_booking_value + AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_8.average_booking_value + subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.booking__is_instant + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.booking__is_instant + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value 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_2.average_booking_value AS average_booking_value + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.average_booking_value + subq_10.listing + , subq_10.booking__is_instant + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_8 - ) subq_9 - ) subq_10 - ) subq_11 + ) subq_17 + ) subq_18 + ) subq_19 + ) subq_20 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.bookings + subq_31.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_21.bookings) AS bookings + SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_20.bookings + subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.booking__is_instant - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.booking__is_instant + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_18.booking__is_instant - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.listing AS listing - , subq_14.booking__is_instant AS booking__is_instant - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.listing AS listing + , subq_23.booking__is_instant AS booking__is_instant + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_13.listing - , subq_13.booking__is_instant - , subq_13.bookings + subq_22.listing + , subq_22.booking__is_instant + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_20 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_29 + ) subq_30 + ) subq_31 + ) subq_32 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_29.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_28.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_27.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 -) subq_32 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0_optimized.sql index 14649c62dd..35859d3713 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0_optimized.sql +++ b/metricflow/test/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_44.average_booking_value) AS average_booking_value - , MAX(subq_56.bookings) AS bookings - , MAX(subq_63.booking_value) AS booking_value + MAX(subq_53.average_booking_value) AS average_booking_value + , MAX(subq_65.bookings) AS bookings + , MAX(subq_72.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,17 +22,17 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - bookings_source_src_28001.is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_40 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_49 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_44 + ) subq_53 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -44,9 +44,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_47.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_47.bookings AS bookings + subq_56.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_56.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -55,15 +55,15 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_47 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_56 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_47.listing = listings_latest_src_28005.listing_id - ) subq_52 + subq_56.listing = listings_latest_src_28000.listing_id + ) subq_61 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_56 + ) subq_65 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -78,9 +78,9 @@ FROM ( SELECT is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_59 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_68 WHERE booking__is_instant - ) subq_63 - ) subq_64 -) subq_65 + ) subq_72 + ) subq_73 +) subq_74 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0.sql index d69db7c4d1..cc97198ea3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0.sql @@ -1,339 +1,339 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - DATEADD(day, -2, subq_9.metric_time__day) = subq_8.metric_time__day -) subq_11 + DATEADD(day, -2, subq_18.metric_time__day) = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0_optimized.sql index e9df61ae2f..a1458a856e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -19,23 +19,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - DATEADD(day, -5, subq_15.ds) = subq_13.metric_time__day + DATEADD(day, -5, subq_24.ds) = subq_22.metric_time__day GROUP BY - subq_15.ds - ) subq_19 - ) subq_20 + subq_24.ds + ) subq_28 + ) subq_29 ON - DATEADD(day, -2, subq_22.ds) = subq_20.metric_time__day -) subq_23 + DATEADD(day, -2, subq_31.ds) = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0.sql index eb9ec0165d..e88e6e69eb 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0.sql @@ -1,340 +1,340 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - WHERE subq_10.ds BETWEEN '2020-01-12' AND '2020-01-13' - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + WHERE subq_19.ds BETWEEN '2020-01-12' AND '2020-01-13' + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - DATEADD(day, -2, subq_9.metric_time__day) = subq_8.metric_time__day -) subq_11 + DATEADD(day, -2, subq_18.metric_time__day) = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 82beb8296d..ce05de9f1e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_21.metric_time__day AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once + subq_30.metric_time__day AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_22 + FROM ***************************.mf_time_spine subq_31 WHERE ds BETWEEN '2020-01-12' AND '2020-01-13' - ) subq_21 + ) subq_30 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -25,23 +25,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - DATEADD(day, -5, subq_15.ds) = subq_13.metric_time__day + DATEADD(day, -5, subq_24.ds) = subq_22.metric_time__day GROUP BY - subq_15.ds - ) subq_19 - ) subq_20 + subq_24.ds + ) subq_28 + ) subq_29 ON - DATEADD(day, -2, subq_21.metric_time__day) = subq_20.metric_time__day -) subq_23 + DATEADD(day, -2, subq_30.metric_time__day) = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0.sql index f1450394bf..6d24f5ad41 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0.sql @@ -1,346 +1,346 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day + subq_21.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - DATEADD(day, -2, subq_9.metric_time__day) = subq_8.metric_time__day - ) subq_11 + DATEADD(day, -2, subq_18.metric_time__day) = subq_17.metric_time__day + ) subq_20 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_12 +) subq_21 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0_optimized.sql index e17438d2ae..533c803d41 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -10,9 +10,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,25 +24,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.ds AS metric_time__day - , SUM(subq_14.bookings) AS bookings - FROM ***************************.mf_time_spine subq_16 + subq_25.ds AS metric_time__day + , SUM(subq_23.bookings) AS bookings + FROM ***************************.mf_time_spine subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_14 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_23 ON - DATEADD(day, -5, subq_16.ds) = subq_14.metric_time__day + DATEADD(day, -5, subq_25.ds) = subq_23.metric_time__day GROUP BY - subq_16.ds - ) subq_20 - ) subq_21 + subq_25.ds + ) subq_29 + ) subq_30 ON - DATEADD(day, -2, subq_23.ds) = subq_21.metric_time__day - ) subq_24 + DATEADD(day, -2, subq_32.ds) = subq_30.metric_time__day + ) subq_33 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_25 +) subq_34 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0.sql index ef9c33f743..aa280117c8 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__ds__day - ) subq_3 - ) subq_4 + subq_11.booking__ds__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.booking__ds__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.booking__ds__day) = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.booking__ds__day) = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql index 1b7dbc4725..9f6d4b5769 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.booking__ds__day + DATE_TRUNC('month', subq_31.ds) = subq_29.booking__ds__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0.sql index 0701b57ece..9c38493814 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__ds__day - ) subq_3 - ) subq_4 + subq_11.booking__ds__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.booking__ds__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATEADD(day, -14, subq_7.booking__ds__day) = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + DATEADD(day, -14, subq_16.booking__ds__day) = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0_optimized.sql index 272991a8dc..dc58b2992d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATEADD(day, -14, subq_22.ds) = subq_20.booking__ds__day + DATEADD(day, -14, subq_31.ds) = subq_29.booking__ds__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0.sql index b345b836f4..f8f523b0a8 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0.sql @@ -1,320 +1,320 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - WHERE subq_3.ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + WHERE subq_12.ds BETWEEN '2019-12-19' AND '2020-01-02' + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATEADD(day, -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 -) subq_7 + subq_14.metric_time__day + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0_optimized.sql index ee1dcbf475..f3a30decfa 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -8,25 +8,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago + subq_19.metric_time__day AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_20 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' - ) subq_10 + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - DATEADD(day, -5, subq_10.metric_time__day) = subq_9.metric_time__day + DATEADD(day, -5, subq_19.metric_time__day) = subq_18.metric_time__day GROUP BY - subq_10.metric_time__day -) subq_15 + subq_19.metric_time__day +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index b1008b201f..5760a8a847 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -1,441 +1,441 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.bookers AS every_2_days_bookers_2_days_ago + subq_19.metric_time__day + , subq_19.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , COUNT(DISTINCT subq_9.bookers) AS bookers + subq_18.metric_time__day + , COUNT(DISTINCT subq_18.bookers) AS bookers FROM ( -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] SELECT - subq_8.metric_time__day - , subq_8.bookers + subq_17.metric_time__day + , subq_17.bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + WHERE subq_15.ds BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATE_ADD('day', -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATE_ADD('day', -2, subq_11.metric_time__day) ) - ) subq_4 + ) subq_13 ON - DATE_ADD('day', -2, subq_5.metric_time__day) = subq_4.metric_time__day - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' - ) subq_9 + DATE_ADD('day', -2, subq_14.metric_time__day) = subq_13.metric_time__day + ) subq_16 + ) subq_17 + WHERE subq_17.metric_time__day BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 -) subq_11 + subq_18.metric_time__day + ) subq_19 +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index 1cbb7e47da..780f613cce 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -9,33 +9,33 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day AS metric_time__day - , COUNT(DISTINCT subq_16.bookers) AS every_2_days_bookers_2_days_ago + subq_26.metric_time__day AS metric_time__day + , COUNT(DISTINCT subq_25.bookers) AS every_2_days_bookers_2_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_18 + FROM ***************************.mf_time_spine subq_27 WHERE ds BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' - ) subq_17 + ) subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_15.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_24 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_15.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_24.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATE_ADD('day', -2, subq_15.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_24.ds) ) - ) subq_16 + ) subq_25 ON - DATE_ADD('day', -2, subq_17.metric_time__day) = subq_16.metric_time__day - WHERE subq_17.metric_time__day BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' + DATE_ADD('day', -2, subq_26.metric_time__day) = subq_25.metric_time__day + WHERE subq_26.metric_time__day BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' GROUP BY - subq_17.metric_time__day -) subq_23 + subq_26.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric__plan0.sql index 3463247221..2eed8517a2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric__plan0.sql @@ -1,445 +1,445 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_16.metric_time__day + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) -) subq_10 + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric__plan0_optimized.sql index 23f7234c6e..1638560b4d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , MAX(subq_15.ref_bookings) AS ref_bookings - , MAX(subq_20.bookings) AS bookings + COALESCE(subq_24.metric_time__day, subq_29.metric_time__day) AS metric_time__day + , MAX(subq_24.ref_bookings) AS ref_bookings + , MAX(subq_29.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,11 +21,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 GROUP BY metric_time__day - ) subq_15 + ) subq_24 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,13 +39,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_15.metric_time__day = subq_20.metric_time__day + subq_24.metric_time__day = subq_29.metric_time__day GROUP BY - COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) -) subq_21 + COALESCE(subq_24.metric_time__day, subq_29.metric_time__day) +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index 882a8d8d02..4a4a5cd2b5 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -1,73 +1,73 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__month + subq_9.metric_time__month , bookings_last_month AS bookings_last_month FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , subq_6.bookings_monthly AS bookings_last_month + subq_8.metric_time__month + , subq_8.bookings_monthly AS bookings_last_month FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__month - , SUM(subq_5.bookings_monthly) AS bookings_monthly + subq_7.metric_time__month + , SUM(subq_7.bookings_monthly) AS bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_4.metric_time__month - , subq_4.bookings_monthly + subq_6.metric_time__month + , subq_6.bookings_monthly FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__month AS metric_time__month - , subq_1.monthly_ds__month AS monthly_ds__month - , subq_1.monthly_ds__quarter AS monthly_ds__quarter - , subq_1.monthly_ds__year AS monthly_ds__year - , subq_1.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_1.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_1.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_1.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_1.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_1.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_1.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_1.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_1.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_1.listing AS listing - , subq_1.booking__listing AS booking__listing - , subq_1.bookings_monthly AS bookings_monthly + subq_4.metric_time__month AS metric_time__month + , subq_3.monthly_ds__month AS monthly_ds__month + , subq_3.monthly_ds__quarter AS monthly_ds__quarter + , subq_3.monthly_ds__year AS monthly_ds__year + , subq_3.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_3.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_3.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_3.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_3.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_3.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_3.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_3.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_3.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_3.listing AS listing + , subq_3.booking__listing AS booking__listing + , subq_3.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_3.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_3 + DATE_TRUNC('month', subq_5.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_5 GROUP BY - DATE_TRUNC('month', subq_3.ds) - ) subq_2 + DATE_TRUNC('month', subq_5.ds) + ) subq_4 INNER JOIN ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_0.monthly_ds__month - , subq_0.monthly_ds__quarter - , subq_0.monthly_ds__year - , subq_0.monthly_ds__extract_year - , subq_0.monthly_ds__extract_quarter - , subq_0.monthly_ds__extract_month - , subq_0.booking__monthly_ds__month - , subq_0.booking__monthly_ds__quarter - , subq_0.booking__monthly_ds__year - , subq_0.booking__monthly_ds__extract_year - , subq_0.booking__monthly_ds__extract_quarter - , subq_0.booking__monthly_ds__extract_month - , subq_0.monthly_ds__month AS metric_time__month - , subq_0.monthly_ds__quarter AS metric_time__quarter - , subq_0.monthly_ds__year AS metric_time__year - , subq_0.monthly_ds__extract_year AS metric_time__extract_year - , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.monthly_ds__extract_month AS metric_time__extract_month - , subq_0.listing - , subq_0.booking__listing - , subq_0.bookings_monthly + subq_2.monthly_ds__month + , subq_2.monthly_ds__quarter + , subq_2.monthly_ds__year + , subq_2.monthly_ds__extract_year + , subq_2.monthly_ds__extract_quarter + , subq_2.monthly_ds__extract_month + , subq_2.booking__monthly_ds__month + , subq_2.booking__monthly_ds__quarter + , subq_2.booking__monthly_ds__year + , subq_2.booking__monthly_ds__extract_year + , subq_2.booking__monthly_ds__extract_quarter + , subq_2.booking__monthly_ds__extract_month + , subq_2.monthly_ds__month AS metric_time__month + , subq_2.monthly_ds__quarter AS metric_time__quarter + , subq_2.monthly_ds__year AS metric_time__year + , subq_2.monthly_ds__extract_year AS metric_time__extract_year + , subq_2.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_2.monthly_ds__extract_month AS metric_time__extract_month + , subq_2.listing + , subq_2.booking__listing + , subq_2.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -87,13 +87,13 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_0 - ) subq_1 + ) subq_2 + ) subq_3 ON - DATE_ADD('month', -1, subq_2.metric_time__month) = subq_1.metric_time__month - ) subq_4 - ) subq_5 + DATE_ADD('month', -1, subq_4.metric_time__month) = subq_3.metric_time__month + ) subq_6 + ) subq_7 GROUP BY - subq_5.metric_time__month - ) subq_6 -) subq_7 + subq_7.metric_time__month + ) subq_8 +) subq_9 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql index 8caca07dd3..af55b1fdef 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_month_dimension_and_offset_window__plan0_optimized.sql @@ -8,20 +8,20 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month AS metric_time__month + subq_12.metric_time__month AS metric_time__month , SUM(bookings_monthly_source_src_16000.bookings_monthly) AS bookings_last_month FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_13 GROUP BY DATE_TRUNC('month', ds) - ) subq_10 + ) subq_12 INNER JOIN ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 ON - DATE_ADD('month', -1, subq_10.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_16000.ds) + DATE_ADD('month', -1, subq_12.metric_time__month) = DATE_TRUNC('month', bookings_monthly_source_src_16000.ds) GROUP BY - subq_10.metric_time__month -) subq_15 + subq_12.metric_time__month +) subq_17 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0.sql index 953276bcd3..7dc78f5c01 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__day - ) subq_11 - ) subq_12 + subq_19.metric_time__day + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) -) subq_13 + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 5138fe8ae6..2061be23cf 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day + DATE_TRUNC('month', subq_31.ds) = subq_29.metric_time__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) -) subq_27 + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index 8118b0cde6..491a45ad85 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -1,546 +1,546 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__week + subq_22.metric_time__week , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) AS metric_time__week - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.metric_time__week, subq_21.metric_time__week) AS metric_time__week + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__week - , subq_3.bookings + subq_12.metric_time__week + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__week - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__week + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_1.metric_time__week - , subq_1.bookings + subq_10.metric_time__week + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__week - ) subq_3 - ) subq_4 + subq_11.metric_time__week + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__week - , subq_11.bookings AS bookings_at_start_of_month + subq_20.metric_time__week + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__week - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__week + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__week'] SELECT - subq_9.metric_time__week - , subq_9.bookings + subq_18.metric_time__week + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('week', subq_7.metric_time__day) AS metric_time__week - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('week', subq_16.metric_time__day) AS metric_time__week + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.metric_time__day) = subq_6.metric_time__day - WHERE DATE_TRUNC('week', subq_7.metric_time__day) = subq_7.metric_time__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.metric_time__day) = subq_15.metric_time__day + WHERE DATE_TRUNC('week', subq_16.metric_time__day) = subq_16.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__week - ) subq_11 - ) subq_12 + subq_19.metric_time__week + ) subq_20 + ) subq_21 ON - subq_4.metric_time__week = subq_12.metric_time__week + subq_13.metric_time__week = subq_21.metric_time__week GROUP BY - COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) -) subq_13 + COALESCE(subq_13.metric_time__week, subq_21.metric_time__week) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index b9e4162413..65cf132abd 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) AS metric_time__week - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.metric_time__week, subq_35.metric_time__week) AS metric_time__week + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,36 +21,36 @@ FROM ( SELECT DATE_TRUNC('week', ds) AS metric_time__week , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__week - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__week'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('week', subq_22.ds) AS metric_time__week - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC('week', subq_31.ds) AS metric_time__week + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day - WHERE DATE_TRUNC('week', subq_22.ds) = subq_22.ds + DATE_TRUNC('month', subq_31.ds) = subq_29.metric_time__day + WHERE DATE_TRUNC('week', subq_31.ds) = subq_31.ds GROUP BY - DATE_TRUNC('week', subq_22.ds) - ) subq_26 + DATE_TRUNC('week', subq_31.ds) + ) subq_35 ON - subq_18.metric_time__week = subq_26.metric_time__week + subq_27.metric_time__week = subq_35.metric_time__week GROUP BY - COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) -) subq_27 + COALESCE(subq_27.metric_time__week, subq_35.metric_time__week) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0.sql index b069367191..baeb31f907 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__day - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.metric_time__day AS metric_time__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_ADD('day', -14, subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATE_ADD('day', -14, subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__day - ) subq_11 - ) subq_12 + subq_19.metric_time__day + ) subq_20 + ) subq_21 ON - subq_4.metric_time__day = subq_12.metric_time__day + subq_13.metric_time__day = subq_21.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) -) subq_13 + COALESCE(subq_13.metric_time__day, subq_21.metric_time__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0_optimized.sql index 9f6388e314..82f9be0d8a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) AS metric_time__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_ADD('day', -14, subq_22.ds) = subq_20.metric_time__day + DATE_ADD('day', -14, subq_31.ds) = subq_29.metric_time__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.metric_time__day = subq_26.metric_time__day + subq_27.metric_time__day = subq_35.metric_time__day GROUP BY - COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) -) subq_27 + COALESCE(subq_27.metric_time__day, subq_35.metric_time__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql index fad85dcb51..258aad2845 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__quarter + subq_22.metric_time__quarter , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) AS metric_time__quarter - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__quarter, subq_21.metric_time__quarter) AS metric_time__quarter + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__quarter - , subq_3.bookings + subq_12.metric_time__quarter + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__quarter - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__quarter + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_1.metric_time__quarter - , subq_1.bookings + subq_10.metric_time__quarter + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__quarter - ) subq_3 - ) subq_4 + subq_11.metric_time__quarter + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__quarter - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__quarter + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__quarter - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__quarter + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__quarter'] SELECT - subq_9.metric_time__quarter - , subq_9.bookings + subq_18.metric_time__quarter + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('quarter', subq_7.metric_time__day) AS metric_time__quarter - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('quarter', subq_16.metric_time__day) AS metric_time__quarter + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_ADD('day', -14, subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATE_ADD('day', -14, subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__quarter - ) subq_11 - ) subq_12 + subq_19.metric_time__quarter + ) subq_20 + ) subq_21 ON - subq_4.metric_time__quarter = subq_12.metric_time__quarter + subq_13.metric_time__quarter = subq_21.metric_time__quarter GROUP BY - COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) -) subq_13 + COALESCE(subq_13.metric_time__quarter, subq_21.metric_time__quarter) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index 2be93c882e..9e0717a8cb 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) AS metric_time__quarter - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__quarter, subq_35.metric_time__quarter) AS metric_time__quarter + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('quarter', ds) AS metric_time__quarter , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__quarter - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__quarter'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('quarter', subq_22.ds) AS metric_time__quarter - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + DATE_TRUNC('quarter', subq_31.ds) AS metric_time__quarter + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_ADD('day', -14, subq_22.ds) = subq_20.metric_time__day + DATE_ADD('day', -14, subq_31.ds) = subq_29.metric_time__day GROUP BY - DATE_TRUNC('quarter', subq_22.ds) - ) subq_26 + DATE_TRUNC('quarter', subq_31.ds) + ) subq_35 ON - subq_18.metric_time__quarter = subq_26.metric_time__quarter + subq_27.metric_time__quarter = subq_35.metric_time__quarter GROUP BY - COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) -) subq_27 + COALESCE(subq_27.metric_time__quarter, subq_35.metric_time__quarter) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 19653dcf27..a567501e7c 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -1,645 +1,645 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__day + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC('month', subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 + subq_14.metric_time__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATE_ADD('month', -1, subq_10.metric_time__day) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATE_ADD('month', -1, subq_19.metric_time__day) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__day - ) subq_14 - ) subq_15 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) -) subq_16 + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 8fc39c111b..43920dbf42 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -5,55 +5,55 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_20.ds AS metric_time__day - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + subq_29.ds AS metric_time__day + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day + DATE_TRUNC('month', subq_29.ds) = subq_27.metric_time__day GROUP BY - subq_20.ds - ) subq_24 + subq_29.ds + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATE_ADD('month', -1, subq_28.ds) = subq_26.metric_time__day + DATE_ADD('month', -1, subq_37.ds) = subq_35.metric_time__day GROUP BY - subq_28.ds - ) subq_32 + subq_37.ds + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 91a46fe69e..ff44f2ed0e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -1,646 +1,646 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__year + subq_25.metric_time__year , month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) AS metric_time__year - , MAX(subq_7.month_start_bookings) AS month_start_bookings - , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_16.metric_time__year, subq_24.metric_time__year) AS metric_time__year + , MAX(subq_16.month_start_bookings) AS month_start_bookings + , MAX(subq_24.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__year - , subq_6.bookings AS month_start_bookings + subq_15.metric_time__year + , subq_15.bookings AS month_start_bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__year - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__year + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_4.metric_time__year - , subq_4.bookings + subq_13.metric_time__year + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('year', subq_11.metric_time__day) AS metric_time__year + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - WHERE DATE_TRUNC('year', subq_2.metric_time__day) = subq_2.metric_time__day - ) subq_4 - ) subq_5 + DATE_TRUNC('month', subq_11.metric_time__day) = subq_10.metric_time__day + WHERE DATE_TRUNC('year', subq_11.metric_time__day) = subq_11.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__year - ) subq_6 - ) subq_7 + subq_14.metric_time__year + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__year - , subq_14.bookings AS bookings_1_month_ago + subq_23.metric_time__year + , subq_23.bookings AS bookings_1_month_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__year - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__year + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__year'] SELECT - subq_12.metric_time__year - , subq_12.bookings + subq_21.metric_time__year + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_10.metric_time__day) AS metric_time__year - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + DATE_TRUNC('year', subq_19.metric_time__day) AS metric_time__year + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATE_ADD('month', -1, subq_10.metric_time__day) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATE_ADD('month', -1, subq_19.metric_time__day) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__year - ) subq_14 - ) subq_15 + subq_22.metric_time__year + ) subq_23 + ) subq_24 ON - subq_7.metric_time__year = subq_15.metric_time__year + subq_16.metric_time__year = subq_24.metric_time__year GROUP BY - COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) -) subq_16 + COALESCE(subq_16.metric_time__year, subq_24.metric_time__year) +) subq_25 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index b1468efa5a..b5dcfe8f28 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -5,56 +5,56 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) AS metric_time__year - , MAX(subq_24.month_start_bookings) AS month_start_bookings - , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago + COALESCE(subq_33.metric_time__year, subq_41.metric_time__year) AS metric_time__year + , MAX(subq_33.month_start_bookings) AS month_start_bookings + , MAX(subq_41.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_20.ds) AS metric_time__year - , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + DATE_TRUNC('year', subq_29.ds) AS metric_time__year + , SUM(subq_27.bookings) AS month_start_bookings + FROM ***************************.mf_time_spine subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day - WHERE DATE_TRUNC('year', subq_20.ds) = subq_20.ds + DATE_TRUNC('month', subq_29.ds) = subq_27.metric_time__day + WHERE DATE_TRUNC('year', subq_29.ds) = subq_29.ds GROUP BY - DATE_TRUNC('year', subq_20.ds) - ) subq_24 + DATE_TRUNC('year', subq_29.ds) + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__year'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_28.ds) AS metric_time__year - , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + DATE_TRUNC('year', subq_37.ds) AS metric_time__year + , SUM(subq_35.bookings) AS bookings_1_month_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATE_ADD('month', -1, subq_28.ds) = subq_26.metric_time__day + DATE_ADD('month', -1, subq_37.ds) = subq_35.metric_time__day GROUP BY - DATE_TRUNC('year', subq_28.ds) - ) subq_32 + DATE_TRUNC('year', subq_37.ds) + ) subq_41 ON - subq_24.metric_time__year = subq_32.metric_time__year + subq_33.metric_time__year = subq_41.metric_time__year GROUP BY - COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) -) subq_33 + COALESCE(subq_33.metric_time__year, subq_41.metric_time__year) +) subq_42 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index efd0704145..2372d97277 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_5.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_5.bookings) AS bookings - , MAX(subq_14.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_14.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_14.bookings) AS bookings + , MAX(subq_23.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_3.metric_time__day - , SUM(subq_3.bookings) AS bookings + subq_12.metric_time__day + , SUM(subq_12.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.bookings + subq_11.metric_time__day + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_3 + ) subq_12 GROUP BY - subq_3.metric_time__day - ) subq_4 - ) subq_5 + subq_12.metric_time__day + ) subq_13 + ) subq_14 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.bookings AS bookings_2_weeks_ago + subq_22.metric_time__day + , subq_22.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.bookings) AS bookings + subq_21.metric_time__day + , SUM(subq_21.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings + subq_20.metric_time__day + , subq_20.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_19.metric_time__day + , subq_19.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.ds__day AS ds__day - , subq_7.ds__week AS ds__week - , subq_7.ds__month AS ds__month - , subq_7.ds__quarter AS ds__quarter - , subq_7.ds__year AS ds__year - , subq_7.ds__extract_year AS ds__extract_year - , subq_7.ds__extract_quarter AS ds__extract_quarter - , subq_7.ds__extract_month AS ds__extract_month - , subq_7.ds__extract_day AS ds__extract_day - , subq_7.ds__extract_dow AS ds__extract_dow - , subq_7.ds__extract_doy AS ds__extract_doy - , subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__week AS ds_partitioned__week - , subq_7.ds_partitioned__month AS ds_partitioned__month - , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_7.ds_partitioned__year AS ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_7.paid_at__day AS paid_at__day - , subq_7.paid_at__week AS paid_at__week - , subq_7.paid_at__month AS paid_at__month - , subq_7.paid_at__quarter AS paid_at__quarter - , subq_7.paid_at__year AS paid_at__year - , subq_7.paid_at__extract_year AS paid_at__extract_year - , subq_7.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_7.paid_at__extract_month AS paid_at__extract_month - , subq_7.paid_at__extract_day AS paid_at__extract_day - , subq_7.paid_at__extract_dow AS paid_at__extract_dow - , subq_7.paid_at__extract_doy AS paid_at__extract_doy - , subq_7.booking__ds__day AS booking__ds__day - , subq_7.booking__ds__week AS booking__ds__week - , subq_7.booking__ds__month AS booking__ds__month - , subq_7.booking__ds__quarter AS booking__ds__quarter - , subq_7.booking__ds__year AS booking__ds__year - , subq_7.booking__ds__extract_year AS booking__ds__extract_year - , subq_7.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_7.booking__ds__extract_month AS booking__ds__extract_month - , subq_7.booking__ds__extract_day AS booking__ds__extract_day - , subq_7.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_7.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day AS booking__paid_at__day - , subq_7.booking__paid_at__week AS booking__paid_at__week - , subq_7.booking__paid_at__month AS booking__paid_at__month - , subq_7.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_7.booking__paid_at__year AS booking__paid_at__year - , subq_7.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_7.listing AS listing - , subq_7.guest AS guest - , subq_7.host AS host - , subq_7.booking__listing AS booking__listing - , subq_7.booking__guest AS booking__guest - , subq_7.booking__host AS booking__host - , subq_7.is_instant AS is_instant - , subq_7.booking__is_instant AS booking__is_instant - , subq_7.bookings AS bookings - , subq_7.instant_bookings AS instant_bookings - , subq_7.booking_value AS booking_value - , subq_7.max_booking_value AS max_booking_value - , subq_7.min_booking_value AS min_booking_value - , subq_7.bookers AS bookers - , subq_7.average_booking_value AS average_booking_value - , subq_7.referred_bookings AS referred_bookings - , subq_7.median_booking_value AS median_booking_value - , subq_7.booking_value_p99 AS booking_value_p99 - , subq_7.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_17.metric_time__day AS metric_time__day + , subq_16.ds__day AS ds__day + , subq_16.ds__week AS ds__week + , subq_16.ds__month AS ds__month + , subq_16.ds__quarter AS ds__quarter + , subq_16.ds__year AS ds__year + , subq_16.ds__extract_year AS ds__extract_year + , subq_16.ds__extract_quarter AS ds__extract_quarter + , subq_16.ds__extract_month AS ds__extract_month + , subq_16.ds__extract_day AS ds__extract_day + , subq_16.ds__extract_dow AS ds__extract_dow + , subq_16.ds__extract_doy AS ds__extract_doy + , subq_16.ds_partitioned__day AS ds_partitioned__day + , subq_16.ds_partitioned__week AS ds_partitioned__week + , subq_16.ds_partitioned__month AS ds_partitioned__month + , subq_16.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_16.ds_partitioned__year AS ds_partitioned__year + , subq_16.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_16.paid_at__day AS paid_at__day + , subq_16.paid_at__week AS paid_at__week + , subq_16.paid_at__month AS paid_at__month + , subq_16.paid_at__quarter AS paid_at__quarter + , subq_16.paid_at__year AS paid_at__year + , subq_16.paid_at__extract_year AS paid_at__extract_year + , subq_16.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_16.paid_at__extract_month AS paid_at__extract_month + , subq_16.paid_at__extract_day AS paid_at__extract_day + , subq_16.paid_at__extract_dow AS paid_at__extract_dow + , subq_16.paid_at__extract_doy AS paid_at__extract_doy + , subq_16.booking__ds__day AS booking__ds__day + , subq_16.booking__ds__week AS booking__ds__week + , subq_16.booking__ds__month AS booking__ds__month + , subq_16.booking__ds__quarter AS booking__ds__quarter + , subq_16.booking__ds__year AS booking__ds__year + , subq_16.booking__ds__extract_year AS booking__ds__extract_year + , subq_16.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_16.booking__ds__extract_month AS booking__ds__extract_month + , subq_16.booking__ds__extract_day AS booking__ds__extract_day + , subq_16.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_16.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day AS booking__paid_at__day + , subq_16.booking__paid_at__week AS booking__paid_at__week + , subq_16.booking__paid_at__month AS booking__paid_at__month + , subq_16.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_16.booking__paid_at__year AS booking__paid_at__year + , subq_16.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_16.listing AS listing + , subq_16.guest AS guest + , subq_16.host AS host + , subq_16.booking__listing AS booking__listing + , subq_16.booking__guest AS booking__guest + , subq_16.booking__host AS booking__host + , subq_16.is_instant AS is_instant + , subq_16.booking__is_instant AS booking__is_instant + , subq_16.bookings AS bookings + , subq_16.instant_bookings AS instant_bookings + , subq_16.booking_value AS booking_value + , subq_16.max_booking_value AS max_booking_value + , subq_16.min_booking_value AS min_booking_value + , subq_16.bookers AS bookers + , subq_16.average_booking_value AS average_booking_value + , subq_16.referred_bookings AS referred_bookings + , subq_16.median_booking_value AS median_booking_value + , subq_16.booking_value_p99 AS booking_value_p99 + , subq_16.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_16.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - ) subq_8 + subq_18.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + ) subq_17 INNER JOIN ( -- 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_15.ds__day + , subq_15.ds__week + , subq_15.ds__month + , subq_15.ds__quarter + , subq_15.ds__year + , subq_15.ds__extract_year + , subq_15.ds__extract_quarter + , subq_15.ds__extract_month + , subq_15.ds__extract_day + , subq_15.ds__extract_dow + , subq_15.ds__extract_doy + , subq_15.ds_partitioned__day + , subq_15.ds_partitioned__week + , subq_15.ds_partitioned__month + , subq_15.ds_partitioned__quarter + , subq_15.ds_partitioned__year + , subq_15.ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy + , subq_15.paid_at__day + , subq_15.paid_at__week + , subq_15.paid_at__month + , subq_15.paid_at__quarter + , subq_15.paid_at__year + , subq_15.paid_at__extract_year + , subq_15.paid_at__extract_quarter + , subq_15.paid_at__extract_month + , subq_15.paid_at__extract_day + , subq_15.paid_at__extract_dow + , subq_15.paid_at__extract_doy + , subq_15.booking__ds__day + , subq_15.booking__ds__week + , subq_15.booking__ds__month + , subq_15.booking__ds__quarter + , subq_15.booking__ds__year + , subq_15.booking__ds__extract_year + , subq_15.booking__ds__extract_quarter + , subq_15.booking__ds__extract_month + , subq_15.booking__ds__extract_day + , subq_15.booking__ds__extract_dow + , subq_15.booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day + , subq_15.booking__paid_at__week + , subq_15.booking__paid_at__month + , subq_15.booking__paid_at__quarter + , subq_15.booking__paid_at__year + , subq_15.booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy + , subq_15.ds__day AS metric_time__day + , subq_15.ds__week AS metric_time__week + , subq_15.ds__month AS metric_time__month + , subq_15.ds__quarter AS metric_time__quarter + , subq_15.ds__year AS metric_time__year + , subq_15.ds__extract_year AS metric_time__extract_year + , subq_15.ds__extract_quarter AS metric_time__extract_quarter + , subq_15.ds__extract_month AS metric_time__extract_month + , subq_15.ds__extract_day AS metric_time__extract_day + , subq_15.ds__extract_dow AS metric_time__extract_dow + , subq_15.ds__extract_doy AS metric_time__extract_doy + , subq_15.listing + , subq_15.guest + , subq_15.host + , subq_15.booking__listing + , subq_15.booking__guest + , subq_15.booking__host + , subq_15.is_instant + , subq_15.booking__is_instant + , subq_15.bookings + , subq_15.instant_bookings + , subq_15.booking_value + , subq_15.max_booking_value + , subq_15.min_booking_value + , subq_15.bookers + , subq_15.average_booking_value + , subq_15.referred_bookings + , subq_15.median_booking_value + , subq_15.booking_value_p99 + , subq_15.discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 + , subq_15.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 - ) subq_7 + , 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_15 + ) subq_16 ON - DATE_ADD('day', -14, subq_8.metric_time__day) = subq_7.metric_time__day - ) subq_10 - ) subq_11 + DATE_ADD('day', -14, subq_17.metric_time__day) = subq_16.metric_time__day + ) subq_19 + ) subq_20 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' - ) subq_12 + ) subq_21 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_21.metric_time__day + ) subq_22 + ) subq_23 ON - subq_5.metric_time__day = subq_14.metric_time__day + subq_14.metric_time__day = subq_23.metric_time__day GROUP BY - COALESCE(subq_5.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_14.metric_time__day, subq_23.metric_time__day) +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 87a9badc38..c297fa1282 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_21.bookings) AS bookings - , MAX(subq_30.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_30.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_30.bookings) AS bookings + , MAX(subq_39.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -22,12 +22,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_18 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_27 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_21 + ) subq_30 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -39,26 +39,26 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_25.ds AS metric_time__day - , subq_23.bookings AS bookings - FROM ***************************.mf_time_spine subq_25 + subq_34.ds AS metric_time__day + , subq_32.bookings AS bookings + FROM ***************************.mf_time_spine subq_34 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_23 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_32 ON - DATE_ADD('day', -14, subq_25.ds) = subq_23.metric_time__day - ) subq_27 + DATE_ADD('day', -14, subq_34.ds) = subq_32.metric_time__day + ) subq_36 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day - ) subq_30 + ) subq_39 ON - subq_21.metric_time__day = subq_30.metric_time__day + subq_30.metric_time__day = subq_39.metric_time__day GROUP BY - COALESCE(subq_21.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_30.metric_time__day, subq_39.metric_time__day) +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql index 0568dd7d09..58704f1e96 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql @@ -1,433 +1,433 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookers AS every_2_days_bookers_2_days_ago + subq_18.metric_time__day + , subq_18.bookers AS every_2_days_bookers_2_days_ago FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , COUNT(DISTINCT subq_8.bookers) AS bookers + subq_17.metric_time__day + , COUNT(DISTINCT subq_17.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookers + subq_16.metric_time__day + , subq_16.bookers FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.paid_at__day AS paid_at__day - , subq_4.paid_at__week AS paid_at__week - , subq_4.paid_at__month AS paid_at__month - , subq_4.paid_at__quarter AS paid_at__quarter - , subq_4.paid_at__year AS paid_at__year - , subq_4.paid_at__extract_year AS paid_at__extract_year - , subq_4.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_4.paid_at__extract_month AS paid_at__extract_month - , subq_4.paid_at__extract_day AS paid_at__extract_day - , subq_4.paid_at__extract_dow AS paid_at__extract_dow - , subq_4.paid_at__extract_doy AS paid_at__extract_doy - , subq_4.booking__ds__day AS booking__ds__day - , subq_4.booking__ds__week AS booking__ds__week - , subq_4.booking__ds__month AS booking__ds__month - , subq_4.booking__ds__quarter AS booking__ds__quarter - , subq_4.booking__ds__year AS booking__ds__year - , subq_4.booking__ds__extract_year AS booking__ds__extract_year - , subq_4.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_4.booking__ds__extract_month AS booking__ds__extract_month - , subq_4.booking__ds__extract_day AS booking__ds__extract_day - , subq_4.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_4.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day AS booking__paid_at__day - , subq_4.booking__paid_at__week AS booking__paid_at__week - , subq_4.booking__paid_at__month AS booking__paid_at__month - , subq_4.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_4.booking__paid_at__year AS booking__paid_at__year - , subq_4.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_4.listing AS listing - , subq_4.guest AS guest - , subq_4.host AS host - , subq_4.booking__listing AS booking__listing - , subq_4.booking__guest AS booking__guest - , subq_4.booking__host AS booking__host - , subq_4.is_instant AS is_instant - , subq_4.booking__is_instant AS booking__is_instant - , subq_4.bookings AS bookings - , subq_4.instant_bookings AS instant_bookings - , subq_4.booking_value AS booking_value - , subq_4.max_booking_value AS max_booking_value - , subq_4.min_booking_value AS min_booking_value - , subq_4.bookers AS bookers - , subq_4.average_booking_value AS average_booking_value - , subq_4.referred_bookings AS referred_bookings - , subq_4.median_booking_value AS median_booking_value - , subq_4.booking_value_p99 AS booking_value_p99 - , subq_4.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_14.metric_time__day AS metric_time__day + , subq_13.ds__day AS ds__day + , subq_13.ds__week AS ds__week + , subq_13.ds__month AS ds__month + , subq_13.ds__quarter AS ds__quarter + , subq_13.ds__year AS ds__year + , subq_13.ds__extract_year AS ds__extract_year + , subq_13.ds__extract_quarter AS ds__extract_quarter + , subq_13.ds__extract_month AS ds__extract_month + , subq_13.ds__extract_day AS ds__extract_day + , subq_13.ds__extract_dow AS ds__extract_dow + , subq_13.ds__extract_doy AS ds__extract_doy + , subq_13.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__week AS ds_partitioned__week + , subq_13.ds_partitioned__month AS ds_partitioned__month + , subq_13.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_13.ds_partitioned__year AS ds_partitioned__year + , subq_13.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_13.paid_at__day AS paid_at__day + , subq_13.paid_at__week AS paid_at__week + , subq_13.paid_at__month AS paid_at__month + , subq_13.paid_at__quarter AS paid_at__quarter + , subq_13.paid_at__year AS paid_at__year + , subq_13.paid_at__extract_year AS paid_at__extract_year + , subq_13.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_13.paid_at__extract_month AS paid_at__extract_month + , subq_13.paid_at__extract_day AS paid_at__extract_day + , subq_13.paid_at__extract_dow AS paid_at__extract_dow + , subq_13.paid_at__extract_doy AS paid_at__extract_doy + , subq_13.booking__ds__day AS booking__ds__day + , subq_13.booking__ds__week AS booking__ds__week + , subq_13.booking__ds__month AS booking__ds__month + , subq_13.booking__ds__quarter AS booking__ds__quarter + , subq_13.booking__ds__year AS booking__ds__year + , subq_13.booking__ds__extract_year AS booking__ds__extract_year + , subq_13.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_13.booking__ds__extract_month AS booking__ds__extract_month + , subq_13.booking__ds__extract_day AS booking__ds__extract_day + , subq_13.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_13.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day AS booking__paid_at__day + , subq_13.booking__paid_at__week AS booking__paid_at__week + , subq_13.booking__paid_at__month AS booking__paid_at__month + , subq_13.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_13.booking__paid_at__year AS booking__paid_at__year + , subq_13.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_13.listing AS listing + , subq_13.guest AS guest + , subq_13.host AS host + , subq_13.booking__listing AS booking__listing + , subq_13.booking__guest AS booking__guest + , subq_13.booking__host AS booking__host + , subq_13.is_instant AS is_instant + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS bookings + , subq_13.instant_bookings AS instant_bookings + , subq_13.booking_value AS booking_value + , subq_13.max_booking_value AS max_booking_value + , subq_13.min_booking_value AS min_booking_value + , subq_13.bookers AS bookers + , subq_13.average_booking_value AS average_booking_value + , subq_13.referred_bookings AS referred_bookings + , subq_13.median_booking_value AS median_booking_value + , subq_13.booking_value_p99 AS booking_value_p99 + , subq_13.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - ) subq_5 + subq_15.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + ) subq_14 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATE_ADD('day', -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATE_ADD('day', -2, subq_11.metric_time__day) ) - ) subq_4 + ) subq_13 ON - DATE_ADD('day', -2, subq_5.metric_time__day) = subq_4.metric_time__day - ) subq_7 - ) subq_8 + DATE_ADD('day', -2, subq_14.metric_time__day) = subq_13.metric_time__day + ) subq_16 + ) subq_17 GROUP BY - subq_8.metric_time__day - ) subq_9 -) subq_10 + subq_17.metric_time__day + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0_optimized.sql index cb5e71ee25..f355ef32a7 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -8,26 +8,26 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , COUNT(DISTINCT subq_15.bookers) AS every_2_days_bookers_2_days_ago - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , COUNT(DISTINCT subq_24.bookers) AS every_2_days_bookers_2_days_ago + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_14.ds AS metric_time__day - , bookings_source_src_28001.guest_id AS bookers - FROM ***************************.mf_time_spine subq_14 + subq_23.ds AS metric_time__day + , bookings_source_src_28000.guest_id AS bookers + FROM ***************************.mf_time_spine subq_23 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_23.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATE_ADD('day', -2, subq_14.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_23.ds) ) - ) subq_15 + ) subq_24 ON - DATE_ADD('day', -2, subq_17.ds) = subq_15.metric_time__day + DATE_ADD('day', -2, subq_26.ds) = subq_24.metric_time__day GROUP BY - subq_17.ds -) subq_21 + subq_26.ds +) subq_30 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0.sql index e927d96603..5e44a75079 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_7.booking_value) AS booking_value - , MAX(subq_12.bookers) AS bookers + COALESCE(subq_16.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_16.booking_value) AS booking_value + , MAX(subq_21.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_6.booking__ds__day - , subq_6.booking_value + subq_15.booking__ds__day + , subq_15.booking_value FROM ( -- Aggregate Measures SELECT - subq_5.booking__ds__day - , SUM(subq_5.booking_value) AS booking_value + subq_14.booking__ds__day + , SUM(subq_14.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__ds__day'] SELECT - subq_4.booking__ds__day - , subq_4.booking_value + subq_13.booking__ds__day + , subq_13.booking_value FROM ( -- Join to Time Spine Dataset SELECT - subq_2.booking__ds__day AS booking__ds__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__day AS metric_time__day - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.booking__ds__day AS booking__ds__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_ADD('week', -1, subq_2.booking__ds__day) = subq_1.booking__ds__day - ) subq_4 - ) subq_5 + DATE_ADD('week', -1, subq_11.booking__ds__day) = subq_10.booking__ds__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.booking__ds__day - ) subq_6 - ) subq_7 + subq_14.booking__ds__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookers + subq_20.booking__ds__day + , subq_20.bookers FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , COUNT(DISTINCT subq_10.bookers) AS bookers + subq_19.booking__ds__day + , COUNT(DISTINCT subq_19.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookers + subq_18.booking__ds__day + , subq_18.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 - ) subq_10 + , 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_17 + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_7.booking__ds__day = subq_12.booking__ds__day + subq_16.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_7.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_16.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql index 9608d7923b..8d656d91e4 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql @@ -5,25 +5,25 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_21.booking_value) AS booking_value - , MAX(subq_26.bookers) AS bookers + COALESCE(subq_30.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_30.booking_value) AS booking_value + , MAX(subq_35.bookers) AS bookers FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['booking_value', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS booking__ds__day - , SUM(bookings_source_src_28001.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS booking__ds__day + , SUM(bookings_source_src_28000.booking_value) AS booking_value + FROM ***************************.mf_time_spine subq_26 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON - DATE_ADD('week', -1, subq_17.ds) = DATE_TRUNC('day', bookings_source_src_28001.ds) + DATE_ADD('week', -1, subq_26.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds - ) subq_21 + subq_26.ds + ) subq_30 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -33,12 +33,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , COUNT(DISTINCT guest_id) AS bookers - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_26 + ) subq_35 ON - subq_21.booking__ds__day = subq_26.booking__ds__day + subq_30.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_21.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_30.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql index ff7d5e25e4..a804792c8a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -1,319 +1,319 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_ADD('day', -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_ADD('day', -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 -) subq_7 + subq_14.metric_time__day + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 46a02303b5..32a632c706 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -8,19 +8,19 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago - FROM ***************************.mf_time_spine subq_11 + subq_20.ds AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago + FROM ***************************.mf_time_spine subq_20 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - DATE_ADD('day', -5, subq_11.ds) = subq_9.metric_time__day + DATE_ADD('day', -5, subq_20.ds) = subq_18.metric_time__day GROUP BY - subq_11.ds -) subq_15 + subq_20.ds +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric__plan0.sql index ede4cc3102..a3faeed669 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric__plan0.sql @@ -1,895 +1,895 @@ -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day + subq_31.metric_time__day , non_referred + (instant * 1.0 / bookings) AS instant_plus_non_referred_bookings_pct FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) AS metric_time__day - , MAX(subq_11.non_referred) AS non_referred - , MAX(subq_16.instant) AS instant - , MAX(subq_21.bookings) AS bookings + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day + , MAX(subq_20.non_referred) AS non_referred + , MAX(subq_25.instant) AS instant + , MAX(subq_30.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_19.metric_time__day , (bookings - ref_bookings) * 1.0 / bookings AS non_referred FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.ref_bookings) AS ref_bookings - , MAX(subq_9.bookings) AS bookings + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.ref_bookings) AS ref_bookings + , MAX(subq_18.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.referred_bookings AS ref_bookings + subq_12.metric_time__day + , subq_12.referred_bookings AS ref_bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.referred_bookings) AS referred_bookings + subq_11.metric_time__day + , SUM(subq_11.referred_bookings) AS referred_bookings FROM ( -- Pass Only Elements: ['referred_bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.referred_bookings + subq_10.metric_time__day + , subq_10.referred_bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 + subq_11.metric_time__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings + subq_17.metric_time__day + , subq_17.bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_16.metric_time__day + , SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_16.metric_time__day + ) subq_17 + ) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) - ) subq_10 - ) subq_11 + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day - , subq_15.instant_bookings AS instant + subq_24.metric_time__day + , subq_24.instant_bookings AS instant FROM ( -- Aggregate Measures SELECT - subq_14.metric_time__day - , SUM(subq_14.instant_bookings) AS instant_bookings + subq_23.metric_time__day + , SUM(subq_23.instant_bookings) AS instant_bookings FROM ( -- Pass Only Elements: ['instant_bookings', 'metric_time__day'] SELECT - subq_13.metric_time__day - , subq_13.instant_bookings + subq_22.metric_time__day + , subq_22.instant_bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 GROUP BY - subq_14.metric_time__day - ) subq_15 - ) subq_16 + subq_23.metric_time__day + ) subq_24 + ) subq_25 ON - subq_11.metric_time__day = subq_16.metric_time__day + subq_20.metric_time__day = subq_25.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Aggregate Measures SELECT - subq_19.metric_time__day - , SUM(subq_19.bookings) AS bookings + subq_28.metric_time__day + , SUM(subq_28.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.bookings + subq_27.metric_time__day + , subq_27.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_17.ds__day - , subq_17.ds__week - , subq_17.ds__month - , subq_17.ds__quarter - , subq_17.ds__year - , subq_17.ds__extract_year - , subq_17.ds__extract_quarter - , subq_17.ds__extract_month - , subq_17.ds__extract_day - , subq_17.ds__extract_dow - , subq_17.ds__extract_doy - , subq_17.ds_partitioned__day - , subq_17.ds_partitioned__week - , subq_17.ds_partitioned__month - , subq_17.ds_partitioned__quarter - , subq_17.ds_partitioned__year - , subq_17.ds_partitioned__extract_year - , subq_17.ds_partitioned__extract_quarter - , subq_17.ds_partitioned__extract_month - , subq_17.ds_partitioned__extract_day - , subq_17.ds_partitioned__extract_dow - , subq_17.ds_partitioned__extract_doy - , subq_17.paid_at__day - , subq_17.paid_at__week - , subq_17.paid_at__month - , subq_17.paid_at__quarter - , subq_17.paid_at__year - , subq_17.paid_at__extract_year - , subq_17.paid_at__extract_quarter - , subq_17.paid_at__extract_month - , subq_17.paid_at__extract_day - , subq_17.paid_at__extract_dow - , subq_17.paid_at__extract_doy - , subq_17.booking__ds__day - , subq_17.booking__ds__week - , subq_17.booking__ds__month - , subq_17.booking__ds__quarter - , subq_17.booking__ds__year - , subq_17.booking__ds__extract_year - , subq_17.booking__ds__extract_quarter - , subq_17.booking__ds__extract_month - , subq_17.booking__ds__extract_day - , subq_17.booking__ds__extract_dow - , subq_17.booking__ds__extract_doy - , subq_17.booking__ds_partitioned__day - , subq_17.booking__ds_partitioned__week - , subq_17.booking__ds_partitioned__month - , subq_17.booking__ds_partitioned__quarter - , subq_17.booking__ds_partitioned__year - , subq_17.booking__ds_partitioned__extract_year - , subq_17.booking__ds_partitioned__extract_quarter - , subq_17.booking__ds_partitioned__extract_month - , subq_17.booking__ds_partitioned__extract_day - , subq_17.booking__ds_partitioned__extract_dow - , subq_17.booking__ds_partitioned__extract_doy - , subq_17.booking__paid_at__day - , subq_17.booking__paid_at__week - , subq_17.booking__paid_at__month - , subq_17.booking__paid_at__quarter - , subq_17.booking__paid_at__year - , subq_17.booking__paid_at__extract_year - , subq_17.booking__paid_at__extract_quarter - , subq_17.booking__paid_at__extract_month - , subq_17.booking__paid_at__extract_day - , subq_17.booking__paid_at__extract_dow - , subq_17.booking__paid_at__extract_doy - , subq_17.ds__day AS metric_time__day - , subq_17.ds__week AS metric_time__week - , subq_17.ds__month AS metric_time__month - , subq_17.ds__quarter AS metric_time__quarter - , subq_17.ds__year AS metric_time__year - , subq_17.ds__extract_year AS metric_time__extract_year - , subq_17.ds__extract_quarter AS metric_time__extract_quarter - , subq_17.ds__extract_month AS metric_time__extract_month - , subq_17.ds__extract_day AS metric_time__extract_day - , subq_17.ds__extract_dow AS metric_time__extract_dow - , subq_17.ds__extract_doy AS metric_time__extract_doy - , subq_17.listing - , subq_17.guest - , subq_17.host - , subq_17.booking__listing - , subq_17.booking__guest - , subq_17.booking__host - , subq_17.is_instant - , subq_17.booking__is_instant - , subq_17.bookings - , subq_17.instant_bookings - , subq_17.booking_value - , subq_17.max_booking_value - , subq_17.min_booking_value - , subq_17.bookers - , subq_17.average_booking_value - , subq_17.referred_bookings - , subq_17.median_booking_value - , subq_17.booking_value_p99 - , subq_17.discrete_booking_value_p99 - , subq_17.approximate_continuous_booking_value_p99 - , subq_17.approximate_discrete_booking_value_p99 + subq_26.ds__day + , subq_26.ds__week + , subq_26.ds__month + , subq_26.ds__quarter + , subq_26.ds__year + , subq_26.ds__extract_year + , subq_26.ds__extract_quarter + , subq_26.ds__extract_month + , subq_26.ds__extract_day + , subq_26.ds__extract_dow + , subq_26.ds__extract_doy + , subq_26.ds_partitioned__day + , subq_26.ds_partitioned__week + , subq_26.ds_partitioned__month + , subq_26.ds_partitioned__quarter + , subq_26.ds_partitioned__year + , subq_26.ds_partitioned__extract_year + , subq_26.ds_partitioned__extract_quarter + , subq_26.ds_partitioned__extract_month + , subq_26.ds_partitioned__extract_day + , subq_26.ds_partitioned__extract_dow + , subq_26.ds_partitioned__extract_doy + , subq_26.paid_at__day + , subq_26.paid_at__week + , subq_26.paid_at__month + , subq_26.paid_at__quarter + , subq_26.paid_at__year + , subq_26.paid_at__extract_year + , subq_26.paid_at__extract_quarter + , subq_26.paid_at__extract_month + , subq_26.paid_at__extract_day + , subq_26.paid_at__extract_dow + , subq_26.paid_at__extract_doy + , subq_26.booking__ds__day + , subq_26.booking__ds__week + , subq_26.booking__ds__month + , subq_26.booking__ds__quarter + , subq_26.booking__ds__year + , subq_26.booking__ds__extract_year + , subq_26.booking__ds__extract_quarter + , subq_26.booking__ds__extract_month + , subq_26.booking__ds__extract_day + , subq_26.booking__ds__extract_dow + , subq_26.booking__ds__extract_doy + , subq_26.booking__ds_partitioned__day + , subq_26.booking__ds_partitioned__week + , subq_26.booking__ds_partitioned__month + , subq_26.booking__ds_partitioned__quarter + , subq_26.booking__ds_partitioned__year + , subq_26.booking__ds_partitioned__extract_year + , subq_26.booking__ds_partitioned__extract_quarter + , subq_26.booking__ds_partitioned__extract_month + , subq_26.booking__ds_partitioned__extract_day + , subq_26.booking__ds_partitioned__extract_dow + , subq_26.booking__ds_partitioned__extract_doy + , subq_26.booking__paid_at__day + , subq_26.booking__paid_at__week + , subq_26.booking__paid_at__month + , subq_26.booking__paid_at__quarter + , subq_26.booking__paid_at__year + , subq_26.booking__paid_at__extract_year + , subq_26.booking__paid_at__extract_quarter + , subq_26.booking__paid_at__extract_month + , subq_26.booking__paid_at__extract_day + , subq_26.booking__paid_at__extract_dow + , subq_26.booking__paid_at__extract_doy + , subq_26.ds__day AS metric_time__day + , subq_26.ds__week AS metric_time__week + , subq_26.ds__month AS metric_time__month + , subq_26.ds__quarter AS metric_time__quarter + , subq_26.ds__year AS metric_time__year + , subq_26.ds__extract_year AS metric_time__extract_year + , subq_26.ds__extract_quarter AS metric_time__extract_quarter + , subq_26.ds__extract_month AS metric_time__extract_month + , subq_26.ds__extract_day AS metric_time__extract_day + , subq_26.ds__extract_dow AS metric_time__extract_dow + , subq_26.ds__extract_doy AS metric_time__extract_doy + , subq_26.listing + , subq_26.guest + , subq_26.host + , subq_26.booking__listing + , subq_26.booking__guest + , subq_26.booking__host + , subq_26.is_instant + , subq_26.booking__is_instant + , subq_26.bookings + , subq_26.instant_bookings + , subq_26.booking_value + , subq_26.max_booking_value + , subq_26.min_booking_value + , subq_26.bookers + , subq_26.average_booking_value + , subq_26.referred_bookings + , subq_26.median_booking_value + , subq_26.booking_value_p99 + , subq_26.discrete_booking_value_p99 + , subq_26.approximate_continuous_booking_value_p99 + , subq_26.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_17 - ) subq_18 - ) subq_19 + , 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_26 + ) subq_27 + ) subq_28 GROUP BY - subq_19.metric_time__day - ) subq_20 - ) subq_21 + subq_28.metric_time__day + ) subq_29 + ) subq_30 ON - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day) = subq_21.metric_time__day + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day) = subq_30.metric_time__day GROUP BY - COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) -) subq_22 + COALESCE(subq_20.metric_time__day, subq_25.metric_time__day, subq_30.metric_time__day) +) subq_31 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric__plan0_optimized.sql index 78837fdd96..da1e9fdd5a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) AS metric_time__day - , MAX(subq_34.non_referred) AS non_referred - , MAX(subq_39.instant) AS instant - , MAX(subq_44.bookings) AS bookings + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day, subq_53.metric_time__day) AS metric_time__day + , MAX(subq_43.non_referred) AS non_referred + , MAX(subq_48.instant) AS instant + , MAX(subq_53.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -17,9 +17,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.ref_bookings) AS ref_bookings - , MAX(subq_32.bookings) AS bookings + COALESCE(subq_36.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , MAX(subq_36.ref_bookings) AS ref_bookings + , MAX(subq_41.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -33,11 +33,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_25 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_34 GROUP BY metric_time__day - ) subq_27 + ) subq_36 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -51,17 +51,17 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_30 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_39 GROUP BY metric_time__day - ) subq_32 + ) subq_41 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_36.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) - ) subq_33 - ) subq_34 + COALESCE(subq_36.metric_time__day, subq_41.metric_time__day) + ) subq_42 + ) subq_43 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -75,13 +75,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_37 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_46 GROUP BY metric_time__day - ) subq_39 + ) subq_48 ON - subq_34.metric_time__day = subq_39.metric_time__day + subq_43.metric_time__day = subq_48.metric_time__day FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -95,13 +95,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_42 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_51 GROUP BY metric_time__day - ) subq_44 + ) subq_53 ON - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day) = subq_44.metric_time__day + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day) = subq_53.metric_time__day GROUP BY - COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) -) subq_45 + COALESCE(subq_43.metric_time__day, subq_48.metric_time__day, subq_53.metric_time__day) +) subq_54 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 1695f37106..bff5bb988e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -1,359 +1,359 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Pass Only Elements: ['metric_time__day', 'bookings_offset_once'] SELECT - subq_12.metric_time__day - , subq_12.bookings_offset_once + subq_21.metric_time__day + , subq_21.bookings_offset_once FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.booking__is_instant - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.booking__is_instant + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.booking__is_instant AS booking__is_instant - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.booking__is_instant AS booking__is_instant + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant + subq_16.metric_time__day + , subq_16.booking__is_instant , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.bookings + subq_15.metric_time__day + , subq_15.booking__is_instant + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , subq_14.booking__is_instant + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_13.metric_time__day + , subq_13.booking__is_instant + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_ADD('day', -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_ADD('day', -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - , subq_5.booking__is_instant - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + , subq_14.booking__is_instant + ) subq_15 + ) subq_16 + ) subq_17 ON - DATE_ADD('day', -2, subq_9.metric_time__day) = subq_8.metric_time__day - ) subq_11 + DATE_ADD('day', -2, subq_18.metric_time__day) = subq_17.metric_time__day + ) subq_20 WHERE booking__is_instant - ) subq_12 -) subq_13 + ) subq_21 +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index 03646ba7d0..957c5cc0af 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -11,10 +11,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_24.ds AS metric_time__day - , subq_22.booking__is_instant AS booking__is_instant - , subq_22.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_24 + subq_33.ds AS metric_time__day + , subq_31.booking__is_instant AS booking__is_instant + , subq_31.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_33 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -27,10 +27,10 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , subq_15.booking__is_instant AS booking__is_instant - , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine subq_17 + subq_26.ds AS metric_time__day + , subq_24.booking__is_instant AS booking__is_instant + , SUM(subq_24.bookings) AS bookings + FROM ***************************.mf_time_spine subq_26 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -38,17 +38,17 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 ON - DATE_ADD('day', -5, subq_17.ds) = subq_15.metric_time__day + DATE_ADD('day', -5, subq_26.ds) = subq_24.metric_time__day GROUP BY - subq_17.ds - , subq_15.booking__is_instant - ) subq_21 - ) subq_22 + subq_26.ds + , subq_24.booking__is_instant + ) subq_30 + ) subq_31 ON - DATE_ADD('day', -2, subq_24.ds) = subq_22.metric_time__day - ) subq_25 + DATE_ADD('day', -2, subq_33.ds) = subq_31.metric_time__day + ) subq_34 WHERE booking__is_instant -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql index fec5a20b16..a4c2d8beb4 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql @@ -1,471 +1,471 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day + subq_24.metric_time__day , booking_fees - booking_fees_start_of_month AS booking_fees_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_8.metric_time__day, subq_14.metric_time__day) AS metric_time__day - , MAX(subq_8.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_14.booking_fees) AS booking_fees + COALESCE(subq_17.metric_time__day, subq_23.metric_time__day) AS metric_time__day + , MAX(subq_17.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_23.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.booking_fees_start_of_month AS booking_fees_start_of_month + subq_15.metric_time__day AS metric_time__day + , subq_14.booking_fees_start_of_month AS booking_fees_start_of_month FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_6 + subq_16.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + ) subq_15 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_4.metric_time__day + subq_13.metric_time__day , booking_value * 0.05 AS booking_fees_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.booking_value) AS booking_value + subq_11.metric_time__day + , SUM(subq_11.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 - ) subq_4 - ) subq_5 + subq_11.metric_time__day + ) subq_12 + ) subq_13 + ) subq_14 ON - DATE_TRUNC('month', subq_6.metric_time__day) = subq_5.metric_time__day - ) subq_8 + DATE_TRUNC('month', subq_15.metric_time__day) = subq_14.metric_time__day + ) subq_17 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day + subq_22.metric_time__day , booking_value * 0.05 AS booking_fees FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value + subq_21.metric_time__day + , subq_21.booking_value FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_20.metric_time__day + , SUM(subq_20.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_19.metric_time__day + , subq_19.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__extract_quarter - , subq_9.ds__extract_month - , subq_9.ds__extract_day - , subq_9.ds__extract_dow - , subq_9.ds__extract_doy - , subq_9.ds_partitioned__day - , subq_9.ds_partitioned__week - , subq_9.ds_partitioned__month - , subq_9.ds_partitioned__quarter - , subq_9.ds_partitioned__year - , subq_9.ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy - , subq_9.paid_at__day - , subq_9.paid_at__week - , subq_9.paid_at__month - , subq_9.paid_at__quarter - , subq_9.paid_at__year - , subq_9.paid_at__extract_year - , subq_9.paid_at__extract_quarter - , subq_9.paid_at__extract_month - , subq_9.paid_at__extract_day - , subq_9.paid_at__extract_dow - , subq_9.paid_at__extract_doy - , subq_9.booking__ds__day - , subq_9.booking__ds__week - , subq_9.booking__ds__month - , subq_9.booking__ds__quarter - , subq_9.booking__ds__year - , subq_9.booking__ds__extract_year - , subq_9.booking__ds__extract_quarter - , subq_9.booking__ds__extract_month - , subq_9.booking__ds__extract_day - , subq_9.booking__ds__extract_dow - , subq_9.booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day - , subq_9.booking__paid_at__week - , subq_9.booking__paid_at__month - , subq_9.booking__paid_at__quarter - , subq_9.booking__paid_at__year - , subq_9.booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy - , subq_9.ds__day AS metric_time__day - , subq_9.ds__week AS metric_time__week - , subq_9.ds__month AS metric_time__month - , subq_9.ds__quarter AS metric_time__quarter - , subq_9.ds__year AS metric_time__year - , subq_9.ds__extract_year AS metric_time__extract_year - , subq_9.ds__extract_quarter AS metric_time__extract_quarter - , subq_9.ds__extract_month AS metric_time__extract_month - , subq_9.ds__extract_day AS metric_time__extract_day - , subq_9.ds__extract_dow AS metric_time__extract_dow - , subq_9.ds__extract_doy AS metric_time__extract_doy - , subq_9.listing - , subq_9.guest - , subq_9.host - , subq_9.booking__listing - , subq_9.booking__guest - , subq_9.booking__host - , subq_9.is_instant - , subq_9.booking__is_instant - , subq_9.bookings - , subq_9.instant_bookings - , subq_9.booking_value - , subq_9.max_booking_value - , subq_9.min_booking_value - , subq_9.bookers - , subq_9.average_booking_value - , subq_9.referred_bookings - , subq_9.median_booking_value - , subq_9.booking_value_p99 - , subq_9.discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 + 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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 - ) subq_10 - ) subq_11 + , 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_18 + ) subq_19 + ) subq_20 GROUP BY - subq_11.metric_time__day - ) subq_12 - ) subq_13 - ) subq_14 + subq_20.metric_time__day + ) subq_21 + ) subq_22 + ) subq_23 ON - subq_8.metric_time__day = subq_14.metric_time__day + subq_17.metric_time__day = subq_23.metric_time__day GROUP BY - COALESCE(subq_8.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_17.metric_time__day, subq_23.metric_time__day) +) subq_24 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql index fc648c54b6..b28105f311 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_24.booking_fees_start_of_month) AS booking_fees_start_of_month - , MAX(subq_30.booking_fees) AS booking_fees + COALESCE(subq_33.metric_time__day, subq_39.metric_time__day) AS metric_time__day + , MAX(subq_33.booking_fees_start_of_month) AS booking_fees_start_of_month + , MAX(subq_39.booking_fees) AS booking_fees FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.booking_fees_start_of_month AS booking_fees_start_of_month - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.booking_fees_start_of_month AS booking_fees_start_of_month + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -28,14 +28,14 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 ON - DATE_TRUNC('month', subq_23.ds) = subq_21.metric_time__day - ) subq_24 + DATE_TRUNC('month', subq_32.ds) = subq_30.metric_time__day + ) subq_33 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT @@ -50,13 +50,13 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_29 - ) subq_30 + ) subq_38 + ) subq_39 ON - subq_24.metric_time__day = subq_30.metric_time__day + subq_33.metric_time__day = subq_39.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_33.metric_time__day, subq_39.metric_time__day) +) subq_40 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0.sql index 063f570ca7..d64296c825 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0.sql @@ -8,991 +8,991 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_30.booking_value) AS booking_value + MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.average_booking_value + subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_9.average_booking_value) AS average_booking_value + AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_8.average_booking_value + subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.booking__is_instant + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.booking__is_instant + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value 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_2.average_booking_value AS average_booking_value + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.average_booking_value + subq_10.listing + , subq_10.booking__is_instant + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_8 - ) subq_9 - ) subq_10 - ) subq_11 + ) subq_17 + ) subq_18 + ) subq_19 + ) subq_20 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.bookings + subq_31.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_21.bookings) AS bookings + SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_20.bookings + subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.booking__is_instant - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.booking__is_instant + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_18.booking__is_instant - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.listing AS listing - , subq_14.booking__is_instant AS booking__is_instant - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.listing AS listing + , subq_23.booking__is_instant AS booking__is_instant + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_13.listing - , subq_13.booking__is_instant - , subq_13.bookings + subq_22.listing + , subq_22.booking__is_instant + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_20 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_29 + ) subq_30 + ) subq_31 + ) subq_32 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_29.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_28.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_27.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 -) subq_32 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0_optimized.sql index 14649c62dd..35859d3713 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0_optimized.sql +++ b/metricflow/test/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_44.average_booking_value) AS average_booking_value - , MAX(subq_56.bookings) AS bookings - , MAX(subq_63.booking_value) AS booking_value + MAX(subq_53.average_booking_value) AS average_booking_value + , MAX(subq_65.bookings) AS bookings + , MAX(subq_72.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,17 +22,17 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - bookings_source_src_28001.is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + bookings_source_src_28000.is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_40 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_49 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_44 + ) subq_53 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -44,9 +44,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_47.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_47.bookings AS bookings + subq_56.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_56.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -55,15 +55,15 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_47 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_56 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_47.listing = listings_latest_src_28005.listing_id - ) subq_52 + subq_56.listing = listings_latest_src_28000.listing_id + ) subq_61 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_56 + ) subq_65 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -78,9 +78,9 @@ FROM ( SELECT is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_59 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_68 WHERE booking__is_instant - ) subq_63 - ) subq_64 -) subq_65 + ) subq_72 + ) subq_73 +) subq_74 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0.sql index 56e552e360..9f5c725c91 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0.sql @@ -1,339 +1,339 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_ADD('day', -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_ADD('day', -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - DATE_ADD('day', -2, subq_9.metric_time__day) = subq_8.metric_time__day -) subq_11 + DATE_ADD('day', -2, subq_18.metric_time__day) = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0_optimized.sql index 0284eb56c4..7d94e2ba26 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -19,23 +19,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - DATE_ADD('day', -5, subq_15.ds) = subq_13.metric_time__day + DATE_ADD('day', -5, subq_24.ds) = subq_22.metric_time__day GROUP BY - subq_15.ds - ) subq_19 - ) subq_20 + subq_24.ds + ) subq_28 + ) subq_29 ON - DATE_ADD('day', -2, subq_22.ds) = subq_20.metric_time__day -) subq_23 + DATE_ADD('day', -2, subq_31.ds) = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0.sql index ded5076dda..55035f5d67 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0.sql @@ -1,340 +1,340 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day + subq_20.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - WHERE subq_10.ds BETWEEN timestamp '2020-01-12' AND timestamp '2020-01-13' - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + WHERE subq_19.ds BETWEEN timestamp '2020-01-12' AND timestamp '2020-01-13' + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_ADD('day', -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_ADD('day', -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - DATE_ADD('day', -2, subq_9.metric_time__day) = subq_8.metric_time__day -) subq_11 + DATE_ADD('day', -2, subq_18.metric_time__day) = subq_17.metric_time__day +) subq_20 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 68af9338c0..1e7bce1fc2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -5,15 +5,15 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_21.metric_time__day AS metric_time__day - , subq_20.bookings_offset_once AS bookings_offset_once + subq_30.metric_time__day AS metric_time__day + , subq_29.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_22 + FROM ***************************.mf_time_spine subq_31 WHERE ds BETWEEN timestamp '2020-01-12' AND timestamp '2020-01-13' - ) subq_21 + ) subq_30 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -25,23 +25,23 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day - , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + subq_24.ds AS metric_time__day + , SUM(subq_22.bookings) AS bookings + FROM ***************************.mf_time_spine subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 ON - DATE_ADD('day', -5, subq_15.ds) = subq_13.metric_time__day + DATE_ADD('day', -5, subq_24.ds) = subq_22.metric_time__day GROUP BY - subq_15.ds - ) subq_19 - ) subq_20 + subq_24.ds + ) subq_28 + ) subq_29 ON - DATE_ADD('day', -2, subq_21.metric_time__day) = subq_20.metric_time__day -) subq_23 + DATE_ADD('day', -2, subq_30.metric_time__day) = subq_29.metric_time__day +) subq_32 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0.sql index b0f716b25b..a61707182e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0.sql @@ -1,346 +1,346 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day + subq_21.metric_time__day , 2 * bookings_offset_once AS bookings_offset_twice FROM ( -- Constrain Output with WHERE SELECT - subq_11.metric_time__day - , subq_11.bookings_offset_once + subq_20.metric_time__day + , subq_20.bookings_offset_once FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings_offset_once AS bookings_offset_once + subq_18.metric_time__day AS metric_time__day + , subq_17.bookings_offset_once AS bookings_offset_once FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_19.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_19 + ) subq_18 INNER JOIN ( -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , 2 * bookings AS bookings_offset_once FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_15.metric_time__day + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_ADD('day', -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_ADD('day', -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 - ) subq_7 - ) subq_8 + subq_14.metric_time__day + ) subq_15 + ) subq_16 + ) subq_17 ON - DATE_ADD('day', -2, subq_9.metric_time__day) = subq_8.metric_time__day - ) subq_11 + DATE_ADD('day', -2, subq_18.metric_time__day) = subq_17.metric_time__day + ) subq_20 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_12 +) subq_21 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0_optimized.sql index bc54c5e53a..46a3fdc374 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -10,9 +10,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day - , subq_21.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_23 + subq_32.ds AS metric_time__day + , subq_30.bookings_offset_once AS bookings_offset_once + FROM ***************************.mf_time_spine subq_32 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,25 +24,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.ds AS metric_time__day - , SUM(subq_14.bookings) AS bookings - FROM ***************************.mf_time_spine subq_16 + subq_25.ds AS metric_time__day + , SUM(subq_23.bookings) AS bookings + FROM ***************************.mf_time_spine subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_14 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_23 ON - DATE_ADD('day', -5, subq_16.ds) = subq_14.metric_time__day + DATE_ADD('day', -5, subq_25.ds) = subq_23.metric_time__day GROUP BY - subq_16.ds - ) subq_20 - ) subq_21 + subq_25.ds + ) subq_29 + ) subq_30 ON - DATE_ADD('day', -2, subq_23.ds) = subq_21.metric_time__day - ) subq_24 + DATE_ADD('day', -2, subq_32.ds) = subq_30.metric_time__day + ) subq_33 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' -) subq_25 +) subq_34 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0.sql index 41630ee0e3..1a32f79790 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_at_start_of_month AS bookings_growth_since_start_of_month FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__ds__day - ) subq_3 - ) subq_4 + subq_11.booking__ds__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_at_start_of_month + subq_20.booking__ds__day + , subq_20.bookings AS bookings_at_start_of_month FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_TRUNC('month', subq_7.booking__ds__day) = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + DATE_TRUNC('month', subq_16.booking__ds__day) = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql index 1b7dbc4725..9f6d4b5769 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_at_start_of_month + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.booking__ds__day + DATE_TRUNC('month', subq_31.ds) = subq_29.booking__ds__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0.sql index fe159ef2fb..d363eaf91d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.booking__ds__day + subq_22.booking__ds__day , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) AS booking__ds__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) AS booking__ds__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_12.booking__ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.booking__ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_1.booking__ds__day - , subq_1.bookings + subq_10.booking__ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__ds__day - ) subq_3 - ) subq_4 + subq_11.booking__ds__day + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.booking__ds__day - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.booking__ds__day + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.booking__ds__day - , SUM(subq_10.bookings) AS bookings + subq_19.booking__ds__day + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_9.booking__ds__day - , subq_9.bookings + subq_18.booking__ds__day + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day - , subq_6.metric_time__week AS metric_time__week - , subq_6.metric_time__month AS metric_time__month - , subq_6.metric_time__quarter AS metric_time__quarter - , subq_6.metric_time__year AS metric_time__year - , subq_6.metric_time__extract_year AS metric_time__extract_year - , subq_6.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_6.metric_time__extract_month AS metric_time__extract_month - , subq_6.metric_time__extract_day AS metric_time__extract_day - , subq_6.metric_time__extract_dow AS metric_time__extract_dow - , subq_6.metric_time__extract_doy AS metric_time__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_16.booking__ds__day AS booking__ds__day + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.metric_time__day AS metric_time__day + , subq_15.metric_time__week AS metric_time__week + , subq_15.metric_time__month AS metric_time__month + , subq_15.metric_time__quarter AS metric_time__quarter + , subq_15.metric_time__year AS metric_time__year + , subq_15.metric_time__extract_year AS metric_time__extract_year + , subq_15.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_15.metric_time__extract_month AS metric_time__extract_month + , subq_15.metric_time__extract_day AS metric_time__extract_day + , subq_15.metric_time__extract_dow AS metric_time__extract_dow + , subq_15.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_ADD('day', -14, subq_7.booking__ds__day) = subq_6.booking__ds__day - ) subq_9 - ) subq_10 + DATE_ADD('day', -14, subq_16.booking__ds__day) = subq_15.booking__ds__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.booking__ds__day - ) subq_11 - ) subq_12 + subq_19.booking__ds__day + ) subq_20 + ) subq_21 ON - subq_4.booking__ds__day = subq_12.booking__ds__day + subq_13.booking__ds__day = subq_21.booking__ds__day GROUP BY - COALESCE(subq_4.booking__ds__day, subq_12.booking__ds__day) -) subq_13 + COALESCE(subq_13.booking__ds__day, subq_21.booking__ds__day) +) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0_optimized.sql index 9768c7970b..5fdb15eed7 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) AS booking__ds__day - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) AS booking__ds__day + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY booking__ds__day - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS booking__ds__day + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS booking__ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_ADD('day', -14, subq_22.ds) = subq_20.booking__ds__day + DATE_ADD('day', -14, subq_31.ds) = subq_29.booking__ds__day GROUP BY - subq_22.ds - ) subq_26 + subq_31.ds + ) subq_35 ON - subq_18.booking__ds__day = subq_26.booking__ds__day + subq_27.booking__ds__day = subq_35.booking__ds__day GROUP BY - COALESCE(subq_18.booking__ds__day, subq_26.booking__ds__day) -) subq_27 + COALESCE(subq_27.booking__ds__day, subq_35.booking__ds__day) +) subq_36 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0.sql index bc434f18c0..9aa6211294 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0.sql @@ -1,320 +1,320 @@ -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day + subq_16.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_5_days_ago + subq_15.metric_time__day + , subq_15.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_14.metric_time__day + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_13.metric_time__day + , subq_13.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - WHERE subq_3.ds BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + WHERE subq_12.ds BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON - DATE_ADD('day', -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 + DATE_ADD('day', -5, subq_11.metric_time__day) = subq_10.metric_time__day + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 -) subq_7 + subq_14.metric_time__day + ) subq_15 +) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0_optimized.sql index 5f9927ab43..25f8d05a83 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -8,25 +8,25 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day AS metric_time__day - , SUM(subq_9.bookings) AS bookings_5_days_ago + subq_19.metric_time__day AS metric_time__day + , SUM(subq_18.bookings) AS bookings_5_days_ago FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 + FROM ***************************.mf_time_spine subq_20 WHERE ds BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' - ) subq_10 + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 ON - DATE_ADD('day', -5, subq_10.metric_time__day) = subq_9.metric_time__day + DATE_ADD('day', -5, subq_19.metric_time__day) = subq_18.metric_time__day GROUP BY - subq_10.metric_time__day -) subq_15 + subq_19.metric_time__day +) subq_24 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 174821d540..0c1597746c 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -191,32 +191,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_28009.ds, day) AS ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC(users_latest_src_28009.ds, day) AS user__ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS user__ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS user__ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS user__ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index b2b0b8cb89..e54eaffeb6 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -6,13 +6,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE user__home_state_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql index 8fdb02c3a8..ebe3631edd 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_28009.ds, day) AS ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC(users_latest_src_28009.ds, day) AS user__ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS user__ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS user__ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS user__ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql index 8be14ae725..4365193bed 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY listing__is_lux_latest , user__home_state_latest diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 0bf21c9a36..90b66576dd 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -191,32 +191,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index b2b0b8cb89..e54eaffeb6 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -6,13 +6,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE user__home_state_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql index 5fd13a23f2..d66932d7d4 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql index bee3a232b6..96c5d5bb3a 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY - listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 1249bf29d4..d736ad0d03 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -191,32 +191,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index b2b0b8cb89..e54eaffeb6 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -6,13 +6,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE user__home_state_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql index 884b765da5..0962aa9958 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql index bee3a232b6..96c5d5bb3a 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/DuckDB/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY - listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 1249bf29d4..d736ad0d03 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -191,32 +191,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index b2b0b8cb89..e54eaffeb6 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -6,13 +6,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE user__home_state_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql index 884b765da5..0962aa9958 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql index bee3a232b6..96c5d5bb3a 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY - listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0.sql index a5c3a47e46..2444ef1956 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -191,32 +191,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index b2b0b8cb89..e54eaffeb6 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -6,13 +6,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE user__home_state_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql index 5258faf635..6ada21e5f4 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql index bee3a232b6..96c5d5bb3a 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY - listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0.sql index f8c8125277..fe092394e6 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -191,32 +191,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index b2b0b8cb89..e54eaffeb6 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -6,13 +6,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE user__home_state_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql index 2d95b7bd1e..651824a182 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql index bee3a232b6..96c5d5bb3a 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY - listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 9015182e72..478b5d81be 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -126,62 +126,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -191,32 +191,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index b2b0b8cb89..e54eaffeb6 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -6,13 +6,13 @@ SELECT FROM ( -- Join Standard Outputs SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id ) subq_8 WHERE user__home_state_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0.sql index 9dea907a17..28f04502f2 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0.sql @@ -66,62 +66,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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'] @@ -131,32 +131,32 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 + 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 diff --git a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0_optimized.sql b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0_optimized.sql index bee3a232b6..96c5d5bb3a 100644 --- a/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimensions_requiring_join__plan0_optimized.sql @@ -1,13 +1,13 @@ -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY - listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0.sql index 6a7bece951..301cc93f48 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0.sql @@ -1,341 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , COALESCE(subq_9.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 + subq_18.metric_time__day + , COALESCE(subq_18.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookers AS bookers + subq_16.metric_time__day AS metric_time__day + , subq_15.bookers AS bookers FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , COUNT(DISTINCT subq_5.bookers) AS bookers + subq_14.metric_time__day + , COUNT(DISTINCT subq_14.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 2 day) + subq_10.metric_time__day > DATE_SUB(CAST(subq_11.metric_time__day AS DATETIME), INTERVAL 2 day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY metric_time__day - ) subq_6 + ) subq_15 ON - subq_7.metric_time__day = subq_6.metric_time__day -) subq_9 + subq_16.metric_time__day = subq_15.metric_time__day +) subq_18 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0_optimized.sql index 0e337eec64..b4d4ef2020 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0_optimized.sql @@ -5,28 +5,28 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_18.ds AS metric_time__day - , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + subq_27.ds AS metric_time__day + , subq_25.bookers AS bookers + FROM ***************************.mf_time_spine subq_27 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures SELECT - subq_13.ds AS metric_time__day - , COUNT(DISTINCT bookings_source_src_28001.guest_id) AS bookers - FROM ***************************.mf_time_spine subq_13 + subq_22.ds AS metric_time__day + , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers + FROM ***************************.mf_time_spine subq_22 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC(bookings_source_src_28001.ds, day) <= subq_13.ds + DATE_TRUNC(bookings_source_src_28000.ds, day) <= subq_22.ds ) AND ( - DATE_TRUNC(bookings_source_src_28001.ds, day) > DATE_SUB(CAST(subq_13.ds AS DATETIME), INTERVAL 2 day) + DATE_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_22.ds AS DATETIME), INTERVAL 2 day) ) GROUP BY metric_time__day - ) subq_16 + ) subq_25 ON - subq_18.ds = subq_16.metric_time__day -) subq_19 + subq_27.ds = subq_25.metric_time__day +) subq_28 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 21e105dc47..b0dfabca63 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_7.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_15.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_16.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_24.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__day - ) subq_3 + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day - ) subq_6 - ) subq_7 + subq_13.metric_time__day = subq_12.metric_time__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_2_weeks_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATE_SUB(CAST(subq_10.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATE_SUB(CAST(subq_19.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY metric_time__day - ) subq_14 - ) subq_15 + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY metric_time__day -) subq_16 +) subq_25 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 6b4e3d1525..35008abda5 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_24.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_32.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_33.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_41.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -16,9 +16,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings AS bookings + FROM ***************************.mf_time_spine subq_31 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -31,39 +31,39 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_19 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_28 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_22.ds = subq_20.metric_time__day - ) subq_23 - ) subq_24 + subq_31.ds = subq_29.metric_time__day + ) subq_32 + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATE_SUB(CAST(subq_28.ds AS DATETIME), INTERVAL 14 day) = subq_26.metric_time__day + DATE_SUB(CAST(subq_37.ds AS DATETIME), INTERVAL 14 day) = subq_35.metric_time__day GROUP BY metric_time__day - ) subq_32 + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY metric_time__day -) subq_33 +) subq_42 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0.sql index b140a40589..b3c8f07f3a 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__day - ) subq_3 + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql index ea9c03e765..1d22bf4c47 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings - FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings + FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day - ) subq_10 + ) subq_19 ON - subq_12.ds = subq_10.metric_time__day -) subq_13 + subq_21.ds = subq_19.metric_time__day +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_month__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_month__plan0.sql index 57771b4b6f..ced55f1f9a 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_month__plan0.sql @@ -1,229 +1,229 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__month + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__month AS metric_time__month - , subq_3.bookings AS bookings + subq_13.metric_time__month AS metric_time__month + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - DATE_TRUNC(subq_5.ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_5 + DATE_TRUNC(subq_14.ds, month) AS metric_time__month + FROM ***************************.mf_time_spine subq_14 GROUP BY metric_time__month - ) subq_4 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__month - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__month + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__month'] SELECT - subq_1.metric_time__month - , subq_1.bookings + subq_10.metric_time__month + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__month - ) subq_3 + ) subq_12 ON - subq_4.metric_time__month = subq_3.metric_time__month -) subq_6 + subq_13.metric_time__month = subq_12.metric_time__month +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_month__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_month__plan0_optimized.sql index 063b7bdc40..31e016c4f0 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_month__plan0_optimized.sql @@ -5,16 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_11.metric_time__month AS metric_time__month - , subq_10.bookings AS bookings + subq_20.metric_time__month AS metric_time__month + , subq_19.bookings AS bookings FROM ( -- Time Spine SELECT DATE_TRUNC(ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_12 + FROM ***************************.mf_time_spine subq_21 GROUP BY metric_time__month - ) subq_11 + ) subq_20 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -27,11 +27,11 @@ FROM ( SELECT DATE_TRUNC(ds, month) AS metric_time__month , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__month - ) subq_10 + ) subq_19 ON - subq_11.metric_time__month = subq_10.metric_time__month -) subq_13 + subq_20.metric_time__month = subq_19.metric_time__month +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql index 23345fe856..9d0086194c 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__is_instant - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__is_instant + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__is_instant - , SUM(subq_2.bookings) AS bookings + subq_11.booking__is_instant + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_1.booking__is_instant - , subq_1.bookings + subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY booking__is_instant -) subq_3 +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql index 3cb5d4ac8a..820fbf315b 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__is_instant -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql index 3aaa8e32ab..5d843c045f 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__paid_at__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__paid_at__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__paid_at__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__paid_at__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__paid_at__day'] SELECT - subq_1.booking__paid_at__day - , subq_1.bookings + subq_10.booking__paid_at__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY booking__paid_at__day -) subq_3 +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql index 291436f549..f588f6007a 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC(paid_at, day) AS booking__paid_at__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__paid_at__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_without_time_spine__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_without_time_spine__plan0.sql index 185e823148..87d176e136 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_without_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_without_time_spine__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine + subq_12.metric_time__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__day -) subq_3 +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql index e4ea18165c..e11bd281b0 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY metric_time__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0.sql index c09a6f8b44..8448a470c7 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0.sql @@ -1,341 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , COALESCE(subq_9.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 + subq_18.metric_time__day + , COALESCE(subq_18.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookers AS bookers + subq_16.metric_time__day AS metric_time__day + , subq_15.bookers AS bookers FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , COUNT(DISTINCT subq_5.bookers) AS bookers + subq_14.metric_time__day + , COUNT(DISTINCT subq_14.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -2, subq_11.metric_time__day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_14.metric_time__day + ) subq_15 ON - subq_7.metric_time__day = subq_6.metric_time__day -) subq_9 + subq_16.metric_time__day = subq_15.metric_time__day +) subq_18 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0_optimized.sql index 2079863ef3..a1994eb52f 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0_optimized.sql @@ -5,28 +5,28 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_18.ds AS metric_time__day - , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + subq_27.ds AS metric_time__day + , subq_25.bookers AS bookers + FROM ***************************.mf_time_spine subq_27 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures SELECT - subq_13.ds AS metric_time__day - , COUNT(DISTINCT bookings_source_src_28001.guest_id) AS bookers - FROM ***************************.mf_time_spine subq_13 + subq_22.ds AS metric_time__day + , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers + FROM ***************************.mf_time_spine subq_22 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_13.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_22.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATEADD(day, -2, subq_13.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_22.ds) ) GROUP BY - subq_13.ds - ) subq_16 + subq_22.ds + ) subq_25 ON - subq_18.ds = subq_16.metric_time__day -) subq_19 + subq_27.ds = subq_25.metric_time__day +) subq_28 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 37194a458f..30bbbf635a 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_7.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_15.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_16.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_24.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day - ) subq_6 - ) subq_7 + subq_13.metric_time__day = subq_12.metric_time__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_2_weeks_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATEADD(day, -14, subq_10.metric_time__day) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATEADD(day, -14, subq_19.metric_time__day) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__day - ) subq_14 - ) subq_15 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) -) subq_16 + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 7d837ba331..d2ed63322e 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_24.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_32.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_33.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_41.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -16,9 +16,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings AS bookings + FROM ***************************.mf_time_spine subq_31 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -31,39 +31,39 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_19 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_28 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_22.ds = subq_20.metric_time__day - ) subq_23 - ) subq_24 + subq_31.ds = subq_29.metric_time__day + ) subq_32 + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATEADD(day, -14, subq_28.ds) = subq_26.metric_time__day + DATEADD(day, -14, subq_37.ds) = subq_35.metric_time__day GROUP BY - subq_28.ds - ) subq_32 + subq_37.ds + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) +) subq_42 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0.sql index b0424616b1..f3e8173038 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql index 88bc47bb27..25b6898e3d 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings - FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings + FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day - ) subq_10 + ) subq_19 ON - subq_12.ds = subq_10.metric_time__day -) subq_13 + subq_21.ds = subq_19.metric_time__day +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_month__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_month__plan0.sql index 9d2c442d71..d726187e7b 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_month__plan0.sql @@ -1,229 +1,229 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__month + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__month AS metric_time__month - , subq_3.bookings AS bookings + subq_13.metric_time__month AS metric_time__month + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_5.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_5 + DATE_TRUNC('month', subq_14.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_14 GROUP BY - DATE_TRUNC('month', subq_5.ds) - ) subq_4 + DATE_TRUNC('month', subq_14.ds) + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__month - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__month + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__month'] SELECT - subq_1.metric_time__month - , subq_1.bookings + subq_10.metric_time__month + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__month - ) subq_3 + subq_11.metric_time__month + ) subq_12 ON - subq_4.metric_time__month = subq_3.metric_time__month -) subq_6 + subq_13.metric_time__month = subq_12.metric_time__month +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_month__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_month__plan0_optimized.sql index 3f0b900958..15f2f4275e 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_month__plan0_optimized.sql @@ -5,16 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_11.metric_time__month AS metric_time__month - , subq_10.bookings AS bookings + subq_20.metric_time__month AS metric_time__month + , subq_19.bookings AS bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_12 + FROM ***************************.mf_time_spine subq_21 GROUP BY DATE_TRUNC('month', ds) - ) subq_11 + ) subq_20 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -27,11 +27,11 @@ FROM ( SELECT DATE_TRUNC('month', ds) AS metric_time__month , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__month - ) subq_10 + ) subq_19 ON - subq_11.metric_time__month = subq_10.metric_time__month -) subq_13 + subq_20.metric_time__month = subq_19.metric_time__month +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql index 9b37073e8e..249ea65139 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__is_instant - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__is_instant + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__is_instant - , SUM(subq_2.bookings) AS bookings + subq_11.booking__is_instant + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_1.booking__is_instant - , subq_1.bookings + subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__is_instant -) subq_3 + subq_11.booking__is_instant +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql index 3cb5d4ac8a..820fbf315b 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__is_instant -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql index f3f2cae0dc..b63bee719f 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__paid_at__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__paid_at__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__paid_at__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__paid_at__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__paid_at__day'] SELECT - subq_1.booking__paid_at__day - , subq_1.bookings + subq_10.booking__paid_at__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__paid_at__day -) subq_3 + subq_11.booking__paid_at__day +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql index 9feb4f2769..6a499adb15 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC('day', paid_at) AS booking__paid_at__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__paid_at__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_without_time_spine__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_without_time_spine__plan0.sql index bd90f3eb15..8d75e64ec3 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_without_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_without_time_spine__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine + subq_12.metric_time__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day -) subq_3 + subq_11.metric_time__day +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql index 65ce5f540b..5ef604d794 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY metric_time__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_fill_nulls__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_fill_nulls__plan0.sql index 4af8c98b67..b31982169b 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_fill_nulls__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_fill_nulls__plan0.sql @@ -1,341 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , COALESCE(subq_9.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 + subq_18.metric_time__day + , COALESCE(subq_18.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookers AS bookers + subq_16.metric_time__day AS metric_time__day + , subq_15.bookers AS bookers FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , COUNT(DISTINCT subq_5.bookers) AS bookers + subq_14.metric_time__day + , COUNT(DISTINCT subq_14.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > subq_2.metric_time__day - INTERVAL 2 day + subq_10.metric_time__day > subq_11.metric_time__day - INTERVAL 2 day ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_14.metric_time__day + ) subq_15 ON - subq_7.metric_time__day = subq_6.metric_time__day -) subq_9 + subq_16.metric_time__day = subq_15.metric_time__day +) subq_18 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_fill_nulls__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_fill_nulls__plan0_optimized.sql index 16bfac3fa1..804b24ec10 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_fill_nulls__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_fill_nulls__plan0_optimized.sql @@ -5,28 +5,28 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_18.ds AS metric_time__day - , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + subq_27.ds AS metric_time__day + , subq_25.bookers AS bookers + FROM ***************************.mf_time_spine subq_27 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures SELECT - subq_13.ds AS metric_time__day - , COUNT(DISTINCT bookings_source_src_28001.guest_id) AS bookers - FROM ***************************.mf_time_spine subq_13 + subq_22.ds AS metric_time__day + , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers + FROM ***************************.mf_time_spine subq_22 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_13.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_22.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > subq_13.ds - INTERVAL 2 day + DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_22.ds - INTERVAL 2 day ) GROUP BY - subq_13.ds - ) subq_16 + subq_22.ds + ) subq_25 ON - subq_18.ds = subq_16.metric_time__day -) subq_19 + subq_27.ds = subq_25.metric_time__day +) subq_28 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql index f9f1c97129..2df696c357 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_7.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_15.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_16.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_24.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day - ) subq_6 - ) subq_7 + subq_13.metric_time__day = subq_12.metric_time__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_2_weeks_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - subq_10.metric_time__day - INTERVAL 14 day = subq_9.metric_time__day - ) subq_12 - ) subq_13 + subq_19.metric_time__day - INTERVAL 14 day = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__day - ) subq_14 - ) subq_15 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) -) subq_16 + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index afbbbac44a..305842a51a 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_24.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_32.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_33.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_41.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -16,9 +16,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings AS bookings + FROM ***************************.mf_time_spine subq_31 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -31,39 +31,39 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_19 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_28 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_22.ds = subq_20.metric_time__day - ) subq_23 - ) subq_24 + subq_31.ds = subq_29.metric_time__day + ) subq_32 + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - subq_28.ds - INTERVAL 14 day = subq_26.metric_time__day + subq_37.ds - INTERVAL 14 day = subq_35.metric_time__day GROUP BY - subq_28.ds - ) subq_32 + subq_37.ds + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) +) subq_42 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_metric_time__plan0.sql index e30cf6df5a..5fdf4f37d5 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_metric_time__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql index 88bc47bb27..25b6898e3d 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings - FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings + FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day - ) subq_10 + ) subq_19 ON - subq_12.ds = subq_10.metric_time__day -) subq_13 + subq_21.ds = subq_19.metric_time__day +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_month__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_month__plan0.sql index 9f01603d12..0706e55e39 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_month__plan0.sql @@ -1,229 +1,229 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__month + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__month AS metric_time__month - , subq_3.bookings AS bookings + subq_13.metric_time__month AS metric_time__month + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_5.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_5 + DATE_TRUNC('month', subq_14.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_14 GROUP BY - DATE_TRUNC('month', subq_5.ds) - ) subq_4 + DATE_TRUNC('month', subq_14.ds) + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__month - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__month + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__month'] SELECT - subq_1.metric_time__month - , subq_1.bookings + subq_10.metric_time__month + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__month - ) subq_3 + subq_11.metric_time__month + ) subq_12 ON - subq_4.metric_time__month = subq_3.metric_time__month -) subq_6 + subq_13.metric_time__month = subq_12.metric_time__month +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_month__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_month__plan0_optimized.sql index 3f0b900958..15f2f4275e 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_month__plan0_optimized.sql @@ -5,16 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_11.metric_time__month AS metric_time__month - , subq_10.bookings AS bookings + subq_20.metric_time__month AS metric_time__month + , subq_19.bookings AS bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_12 + FROM ***************************.mf_time_spine subq_21 GROUP BY DATE_TRUNC('month', ds) - ) subq_11 + ) subq_20 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -27,11 +27,11 @@ FROM ( SELECT DATE_TRUNC('month', ds) AS metric_time__month , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__month - ) subq_10 + ) subq_19 ON - subq_11.metric_time__month = subq_10.metric_time__month -) subq_13 + subq_20.metric_time__month = subq_19.metric_time__month +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql index 8f5d46e0f3..31585eb5b2 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__is_instant - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__is_instant + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__is_instant - , SUM(subq_2.bookings) AS bookings + subq_11.booking__is_instant + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_1.booking__is_instant - , subq_1.bookings + subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__is_instant -) subq_3 + subq_11.booking__is_instant +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql index 3cb5d4ac8a..820fbf315b 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__is_instant -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql index 188a888829..b6a25e8804 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__paid_at__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__paid_at__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__paid_at__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__paid_at__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__paid_at__day'] SELECT - subq_1.booking__paid_at__day - , subq_1.bookings + subq_10.booking__paid_at__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__paid_at__day -) subq_3 + subq_11.booking__paid_at__day +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql index 9feb4f2769..6a499adb15 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC('day', paid_at) AS booking__paid_at__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__paid_at__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_without_time_spine__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_without_time_spine__plan0.sql index e171c1d2a4..74c28295c4 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_without_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_without_time_spine__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine + subq_12.metric_time__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day -) subq_3 + subq_11.metric_time__day +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql index 65ce5f540b..5ef604d794 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY metric_time__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0.sql index f84630c52b..37c037619f 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0.sql @@ -1,341 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , COALESCE(subq_9.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 + subq_18.metric_time__day + , COALESCE(subq_18.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookers AS bookers + subq_16.metric_time__day AS metric_time__day + , subq_15.bookers AS bookers FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , COUNT(DISTINCT subq_5.bookers) AS bookers + subq_14.metric_time__day + , COUNT(DISTINCT subq_14.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > subq_2.metric_time__day - MAKE_INTERVAL(days => 2) + subq_10.metric_time__day > subq_11.metric_time__day - MAKE_INTERVAL(days => 2) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_14.metric_time__day + ) subq_15 ON - subq_7.metric_time__day = subq_6.metric_time__day -) subq_9 + subq_16.metric_time__day = subq_15.metric_time__day +) subq_18 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0_optimized.sql index fa843ae543..5d2b2ffbf5 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0_optimized.sql @@ -5,28 +5,28 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_18.ds AS metric_time__day - , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + subq_27.ds AS metric_time__day + , subq_25.bookers AS bookers + FROM ***************************.mf_time_spine subq_27 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures SELECT - subq_13.ds AS metric_time__day - , COUNT(DISTINCT bookings_source_src_28001.guest_id) AS bookers - FROM ***************************.mf_time_spine subq_13 + subq_22.ds AS metric_time__day + , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers + FROM ***************************.mf_time_spine subq_22 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_13.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_22.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > subq_13.ds - MAKE_INTERVAL(days => 2) + DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_22.ds - MAKE_INTERVAL(days => 2) ) GROUP BY - subq_13.ds - ) subq_16 + subq_22.ds + ) subq_25 ON - subq_18.ds = subq_16.metric_time__day -) subq_19 + subq_27.ds = subq_25.metric_time__day +) subq_28 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 1f4db0ab28..f734c2ed70 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_7.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_15.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_16.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_24.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day - ) subq_6 - ) subq_7 + subq_13.metric_time__day = subq_12.metric_time__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_2_weeks_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - subq_10.metric_time__day - MAKE_INTERVAL(days => 14) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + subq_19.metric_time__day - MAKE_INTERVAL(days => 14) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__day - ) subq_14 - ) subq_15 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) -) subq_16 + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index ad8d634d7d..6cb1e6e62d 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_24.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_32.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_33.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_41.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -16,9 +16,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings AS bookings + FROM ***************************.mf_time_spine subq_31 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -31,39 +31,39 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_19 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_28 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_22.ds = subq_20.metric_time__day - ) subq_23 - ) subq_24 + subq_31.ds = subq_29.metric_time__day + ) subq_32 + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - subq_28.ds - MAKE_INTERVAL(days => 14) = subq_26.metric_time__day + subq_37.ds - MAKE_INTERVAL(days => 14) = subq_35.metric_time__day GROUP BY - subq_28.ds - ) subq_32 + subq_37.ds + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) +) subq_42 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0.sql index e30cf6df5a..5fdf4f37d5 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql index 88bc47bb27..25b6898e3d 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings - FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings + FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day - ) subq_10 + ) subq_19 ON - subq_12.ds = subq_10.metric_time__day -) subq_13 + subq_21.ds = subq_19.metric_time__day +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_month__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_month__plan0.sql index 9f01603d12..0706e55e39 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_month__plan0.sql @@ -1,229 +1,229 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__month + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__month AS metric_time__month - , subq_3.bookings AS bookings + subq_13.metric_time__month AS metric_time__month + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_5.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_5 + DATE_TRUNC('month', subq_14.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_14 GROUP BY - DATE_TRUNC('month', subq_5.ds) - ) subq_4 + DATE_TRUNC('month', subq_14.ds) + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__month - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__month + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__month'] SELECT - subq_1.metric_time__month - , subq_1.bookings + subq_10.metric_time__month + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__month - ) subq_3 + subq_11.metric_time__month + ) subq_12 ON - subq_4.metric_time__month = subq_3.metric_time__month -) subq_6 + subq_13.metric_time__month = subq_12.metric_time__month +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_month__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_month__plan0_optimized.sql index 3f0b900958..15f2f4275e 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_month__plan0_optimized.sql @@ -5,16 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_11.metric_time__month AS metric_time__month - , subq_10.bookings AS bookings + subq_20.metric_time__month AS metric_time__month + , subq_19.bookings AS bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_12 + FROM ***************************.mf_time_spine subq_21 GROUP BY DATE_TRUNC('month', ds) - ) subq_11 + ) subq_20 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -27,11 +27,11 @@ FROM ( SELECT DATE_TRUNC('month', ds) AS metric_time__month , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__month - ) subq_10 + ) subq_19 ON - subq_11.metric_time__month = subq_10.metric_time__month -) subq_13 + subq_20.metric_time__month = subq_19.metric_time__month +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql index 8f5d46e0f3..31585eb5b2 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__is_instant - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__is_instant + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__is_instant - , SUM(subq_2.bookings) AS bookings + subq_11.booking__is_instant + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_1.booking__is_instant - , subq_1.bookings + subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__is_instant -) subq_3 + subq_11.booking__is_instant +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql index 3cb5d4ac8a..820fbf315b 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__is_instant -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql index 188a888829..b6a25e8804 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__paid_at__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__paid_at__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__paid_at__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__paid_at__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__paid_at__day'] SELECT - subq_1.booking__paid_at__day - , subq_1.bookings + subq_10.booking__paid_at__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__paid_at__day -) subq_3 + subq_11.booking__paid_at__day +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql index 9feb4f2769..6a499adb15 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC('day', paid_at) AS booking__paid_at__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__paid_at__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_without_time_spine__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_without_time_spine__plan0.sql index e171c1d2a4..74c28295c4 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_without_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_without_time_spine__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine + subq_12.metric_time__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day -) subq_3 + subq_11.metric_time__day +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql index 65ce5f540b..5ef604d794 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY metric_time__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0.sql index a40769d77f..c0f5b49998 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0.sql @@ -1,341 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , COALESCE(subq_9.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 + subq_18.metric_time__day + , COALESCE(subq_18.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookers AS bookers + subq_16.metric_time__day AS metric_time__day + , subq_15.bookers AS bookers FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , COUNT(DISTINCT subq_5.bookers) AS bookers + subq_14.metric_time__day + , COUNT(DISTINCT subq_14.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -2, subq_11.metric_time__day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_14.metric_time__day + ) subq_15 ON - subq_7.metric_time__day = subq_6.metric_time__day -) subq_9 + subq_16.metric_time__day = subq_15.metric_time__day +) subq_18 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0_optimized.sql index 2079863ef3..a1994eb52f 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0_optimized.sql @@ -5,28 +5,28 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_18.ds AS metric_time__day - , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + subq_27.ds AS metric_time__day + , subq_25.bookers AS bookers + FROM ***************************.mf_time_spine subq_27 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures SELECT - subq_13.ds AS metric_time__day - , COUNT(DISTINCT bookings_source_src_28001.guest_id) AS bookers - FROM ***************************.mf_time_spine subq_13 + subq_22.ds AS metric_time__day + , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers + FROM ***************************.mf_time_spine subq_22 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_13.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_22.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATEADD(day, -2, subq_13.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_22.ds) ) GROUP BY - subq_13.ds - ) subq_16 + subq_22.ds + ) subq_25 ON - subq_18.ds = subq_16.metric_time__day -) subq_19 + subq_27.ds = subq_25.metric_time__day +) subq_28 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql index c1a530e91e..b47083a2f3 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_7.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_15.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_16.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_24.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day - ) subq_6 - ) subq_7 + subq_13.metric_time__day = subq_12.metric_time__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_2_weeks_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATEADD(day, -14, subq_10.metric_time__day) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATEADD(day, -14, subq_19.metric_time__day) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__day - ) subq_14 - ) subq_15 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) -) subq_16 + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 7d837ba331..d2ed63322e 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_24.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_32.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_33.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_41.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -16,9 +16,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings AS bookings + FROM ***************************.mf_time_spine subq_31 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -31,39 +31,39 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_19 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_28 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_22.ds = subq_20.metric_time__day - ) subq_23 - ) subq_24 + subq_31.ds = subq_29.metric_time__day + ) subq_32 + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATEADD(day, -14, subq_28.ds) = subq_26.metric_time__day + DATEADD(day, -14, subq_37.ds) = subq_35.metric_time__day GROUP BY - subq_28.ds - ) subq_32 + subq_37.ds + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) +) subq_42 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0.sql index e926810abf..9cadb47e17 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql index 88bc47bb27..25b6898e3d 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings - FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings + FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day - ) subq_10 + ) subq_19 ON - subq_12.ds = subq_10.metric_time__day -) subq_13 + subq_21.ds = subq_19.metric_time__day +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_month__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_month__plan0.sql index e304528703..18a14849b7 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_month__plan0.sql @@ -1,229 +1,229 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__month + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__month AS metric_time__month - , subq_3.bookings AS bookings + subq_13.metric_time__month AS metric_time__month + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_5.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_5 + DATE_TRUNC('month', subq_14.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_14 GROUP BY - DATE_TRUNC('month', subq_5.ds) - ) subq_4 + DATE_TRUNC('month', subq_14.ds) + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__month - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__month + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__month'] SELECT - subq_1.metric_time__month - , subq_1.bookings + subq_10.metric_time__month + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__month - ) subq_3 + subq_11.metric_time__month + ) subq_12 ON - subq_4.metric_time__month = subq_3.metric_time__month -) subq_6 + subq_13.metric_time__month = subq_12.metric_time__month +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_month__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_month__plan0_optimized.sql index 3f0b900958..15f2f4275e 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_month__plan0_optimized.sql @@ -5,16 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_11.metric_time__month AS metric_time__month - , subq_10.bookings AS bookings + subq_20.metric_time__month AS metric_time__month + , subq_19.bookings AS bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_12 + FROM ***************************.mf_time_spine subq_21 GROUP BY DATE_TRUNC('month', ds) - ) subq_11 + ) subq_20 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -27,11 +27,11 @@ FROM ( SELECT DATE_TRUNC('month', ds) AS metric_time__month , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__month - ) subq_10 + ) subq_19 ON - subq_11.metric_time__month = subq_10.metric_time__month -) subq_13 + subq_20.metric_time__month = subq_19.metric_time__month +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql index a67a43e4d1..00c9c9365d 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__is_instant - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__is_instant + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__is_instant - , SUM(subq_2.bookings) AS bookings + subq_11.booking__is_instant + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_1.booking__is_instant - , subq_1.bookings + subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__is_instant -) subq_3 + subq_11.booking__is_instant +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql index 3cb5d4ac8a..820fbf315b 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__is_instant -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql index a6ff42b4bd..a82cc7bd14 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__paid_at__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__paid_at__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__paid_at__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__paid_at__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__paid_at__day'] SELECT - subq_1.booking__paid_at__day - , subq_1.bookings + subq_10.booking__paid_at__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__paid_at__day -) subq_3 + subq_11.booking__paid_at__day +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql index 9feb4f2769..6a499adb15 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC('day', paid_at) AS booking__paid_at__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__paid_at__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_without_time_spine__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_without_time_spine__plan0.sql index 3775b18a74..7bd10053bd 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_without_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_without_time_spine__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine + subq_12.metric_time__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day -) subq_3 + subq_11.metric_time__day +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql index 65ce5f540b..5ef604d794 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY metric_time__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0.sql index 3ef841df85..255f417cbf 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0.sql @@ -1,341 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , COALESCE(subq_9.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 + subq_18.metric_time__day + , COALESCE(subq_18.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookers AS bookers + subq_16.metric_time__day AS metric_time__day + , subq_15.bookers AS bookers FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , COUNT(DISTINCT subq_5.bookers) AS bookers + subq_14.metric_time__day + , COUNT(DISTINCT subq_14.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -2, subq_11.metric_time__day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_14.metric_time__day + ) subq_15 ON - subq_7.metric_time__day = subq_6.metric_time__day -) subq_9 + subq_16.metric_time__day = subq_15.metric_time__day +) subq_18 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0_optimized.sql index 2079863ef3..a1994eb52f 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0_optimized.sql @@ -5,28 +5,28 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_18.ds AS metric_time__day - , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + subq_27.ds AS metric_time__day + , subq_25.bookers AS bookers + FROM ***************************.mf_time_spine subq_27 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures SELECT - subq_13.ds AS metric_time__day - , COUNT(DISTINCT bookings_source_src_28001.guest_id) AS bookers - FROM ***************************.mf_time_spine subq_13 + subq_22.ds AS metric_time__day + , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers + FROM ***************************.mf_time_spine subq_22 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_13.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_22.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATEADD(day, -2, subq_13.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_22.ds) ) GROUP BY - subq_13.ds - ) subq_16 + subq_22.ds + ) subq_25 ON - subq_18.ds = subq_16.metric_time__day -) subq_19 + subq_27.ds = subq_25.metric_time__day +) subq_28 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 75043b377e..99e0d1016a 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_7.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_15.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_16.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_24.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day - ) subq_6 - ) subq_7 + subq_13.metric_time__day = subq_12.metric_time__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_2_weeks_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATEADD(day, -14, subq_10.metric_time__day) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATEADD(day, -14, subq_19.metric_time__day) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__day - ) subq_14 - ) subq_15 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) -) subq_16 + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 7d837ba331..d2ed63322e 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_24.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_32.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_33.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_41.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -16,9 +16,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings AS bookings + FROM ***************************.mf_time_spine subq_31 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -31,39 +31,39 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_19 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_28 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_22.ds = subq_20.metric_time__day - ) subq_23 - ) subq_24 + subq_31.ds = subq_29.metric_time__day + ) subq_32 + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATEADD(day, -14, subq_28.ds) = subq_26.metric_time__day + DATEADD(day, -14, subq_37.ds) = subq_35.metric_time__day GROUP BY - subq_28.ds - ) subq_32 + subq_37.ds + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) +) subq_42 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0.sql index a455b172a0..81134fe062 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql index 88bc47bb27..25b6898e3d 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings - FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings + FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day - ) subq_10 + ) subq_19 ON - subq_12.ds = subq_10.metric_time__day -) subq_13 + subq_21.ds = subq_19.metric_time__day +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_month__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_month__plan0.sql index 56ed3a2d25..6178bc84c8 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_month__plan0.sql @@ -1,229 +1,229 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__month + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__month AS metric_time__month - , subq_3.bookings AS bookings + subq_13.metric_time__month AS metric_time__month + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_5.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_5 + DATE_TRUNC('month', subq_14.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_14 GROUP BY - DATE_TRUNC('month', subq_5.ds) - ) subq_4 + DATE_TRUNC('month', subq_14.ds) + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__month - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__month + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__month'] SELECT - subq_1.metric_time__month - , subq_1.bookings + subq_10.metric_time__month + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__month - ) subq_3 + subq_11.metric_time__month + ) subq_12 ON - subq_4.metric_time__month = subq_3.metric_time__month -) subq_6 + subq_13.metric_time__month = subq_12.metric_time__month +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_month__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_month__plan0_optimized.sql index 3f0b900958..15f2f4275e 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_month__plan0_optimized.sql @@ -5,16 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_11.metric_time__month AS metric_time__month - , subq_10.bookings AS bookings + subq_20.metric_time__month AS metric_time__month + , subq_19.bookings AS bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_12 + FROM ***************************.mf_time_spine subq_21 GROUP BY DATE_TRUNC('month', ds) - ) subq_11 + ) subq_20 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -27,11 +27,11 @@ FROM ( SELECT DATE_TRUNC('month', ds) AS metric_time__month , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__month - ) subq_10 + ) subq_19 ON - subq_11.metric_time__month = subq_10.metric_time__month -) subq_13 + subq_20.metric_time__month = subq_19.metric_time__month +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql index c285050765..b1966df100 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__is_instant - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__is_instant + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__is_instant - , SUM(subq_2.bookings) AS bookings + subq_11.booking__is_instant + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_1.booking__is_instant - , subq_1.bookings + subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__is_instant -) subq_3 + subq_11.booking__is_instant +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql index 3cb5d4ac8a..820fbf315b 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__is_instant -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql index 5d7ec762a9..a2e01671e2 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__paid_at__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__paid_at__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__paid_at__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__paid_at__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__paid_at__day'] SELECT - subq_1.booking__paid_at__day - , subq_1.bookings + subq_10.booking__paid_at__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__paid_at__day -) subq_3 + subq_11.booking__paid_at__day +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql index 9feb4f2769..6a499adb15 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC('day', paid_at) AS booking__paid_at__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__paid_at__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_without_time_spine__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_without_time_spine__plan0.sql index 0ef53508df..afb10e24ce 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_without_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_without_time_spine__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine + subq_12.metric_time__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day -) subq_3 + subq_11.metric_time__day +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql index 65ce5f540b..5ef604d794 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY metric_time__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0.sql index 7c6e1649bf..04b8403788 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0.sql @@ -1,341 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , COALESCE(subq_9.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 + subq_18.metric_time__day + , COALESCE(subq_18.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookers AS bookers + subq_16.metric_time__day AS metric_time__day + , subq_15.bookers AS bookers FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , COUNT(DISTINCT subq_5.bookers) AS bookers + subq_14.metric_time__day + , COUNT(DISTINCT subq_14.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookers + subq_13.metric_time__day + , subq_13.bookers FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day - , subq_1.ds__week AS ds__week - , subq_1.ds__month AS ds__month - , subq_1.ds__quarter AS ds__quarter - , subq_1.ds__year AS ds__year - , subq_1.ds__extract_year AS ds__extract_year - , subq_1.ds__extract_quarter AS ds__extract_quarter - , subq_1.ds__extract_month AS ds__extract_month - , subq_1.ds__extract_day AS ds__extract_day - , subq_1.ds__extract_dow AS ds__extract_dow - , subq_1.ds__extract_doy AS ds__extract_doy - , subq_1.ds_partitioned__day AS ds_partitioned__day - , subq_1.ds_partitioned__week AS ds_partitioned__week - , subq_1.ds_partitioned__month AS ds_partitioned__month - , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_1.ds_partitioned__year AS ds_partitioned__year - , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_1.paid_at__day AS paid_at__day - , subq_1.paid_at__week AS paid_at__week - , subq_1.paid_at__month AS paid_at__month - , subq_1.paid_at__quarter AS paid_at__quarter - , subq_1.paid_at__year AS paid_at__year - , subq_1.paid_at__extract_year AS paid_at__extract_year - , subq_1.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_1.paid_at__extract_month AS paid_at__extract_month - , subq_1.paid_at__extract_day AS paid_at__extract_day - , subq_1.paid_at__extract_dow AS paid_at__extract_dow - , subq_1.paid_at__extract_doy AS paid_at__extract_doy - , subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking__ds__week AS booking__ds__week - , subq_1.booking__ds__month AS booking__ds__month - , subq_1.booking__ds__quarter AS booking__ds__quarter - , subq_1.booking__ds__year AS booking__ds__year - , subq_1.booking__ds__extract_year AS booking__ds__extract_year - , subq_1.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_1.booking__ds__extract_month AS booking__ds__extract_month - , subq_1.booking__ds__extract_day AS booking__ds__extract_day - , subq_1.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_1.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day AS booking__paid_at__day - , subq_1.booking__paid_at__week AS booking__paid_at__week - , subq_1.booking__paid_at__month AS booking__paid_at__month - , subq_1.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_1.booking__paid_at__year AS booking__paid_at__year - , subq_1.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__week AS metric_time__week - , subq_1.metric_time__month AS metric_time__month - , subq_1.metric_time__quarter AS metric_time__quarter - , subq_1.metric_time__year AS metric_time__year - , subq_1.metric_time__extract_year AS metric_time__extract_year - , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_1.metric_time__extract_month AS metric_time__extract_month - , subq_1.metric_time__extract_day AS metric_time__extract_day - , subq_1.metric_time__extract_dow AS metric_time__extract_dow - , subq_1.metric_time__extract_doy AS metric_time__extract_doy - , subq_1.listing AS listing - , subq_1.guest AS guest - , subq_1.host AS host - , subq_1.booking__listing AS booking__listing - , subq_1.booking__guest AS booking__guest - , subq_1.booking__host AS booking__host - , subq_1.is_instant AS is_instant - , subq_1.booking__is_instant AS booking__is_instant - , subq_1.bookings AS bookings - , subq_1.instant_bookings AS instant_bookings - , subq_1.booking_value AS booking_value - , subq_1.max_booking_value AS max_booking_value - , subq_1.min_booking_value AS min_booking_value - , subq_1.bookers AS bookers - , subq_1.average_booking_value AS average_booking_value - , subq_1.referred_bookings AS referred_bookings - , subq_1.median_booking_value AS median_booking_value - , subq_1.booking_value_p99 AS booking_value_p99 - , subq_1.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_11.metric_time__day AS metric_time__day + , subq_10.ds__day AS ds__day + , subq_10.ds__week AS ds__week + , subq_10.ds__month AS ds__month + , subq_10.ds__quarter AS ds__quarter + , subq_10.ds__year AS ds__year + , subq_10.ds__extract_year AS ds__extract_year + , subq_10.ds__extract_quarter AS ds__extract_quarter + , subq_10.ds__extract_month AS ds__extract_month + , subq_10.ds__extract_day AS ds__extract_day + , subq_10.ds__extract_dow AS ds__extract_dow + , subq_10.ds__extract_doy AS ds__extract_doy + , subq_10.ds_partitioned__day AS ds_partitioned__day + , subq_10.ds_partitioned__week AS ds_partitioned__week + , subq_10.ds_partitioned__month AS ds_partitioned__month + , subq_10.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_10.ds_partitioned__year AS ds_partitioned__year + , subq_10.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_10.paid_at__day AS paid_at__day + , subq_10.paid_at__week AS paid_at__week + , subq_10.paid_at__month AS paid_at__month + , subq_10.paid_at__quarter AS paid_at__quarter + , subq_10.paid_at__year AS paid_at__year + , subq_10.paid_at__extract_year AS paid_at__extract_year + , subq_10.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_10.paid_at__extract_month AS paid_at__extract_month + , subq_10.paid_at__extract_day AS paid_at__extract_day + , subq_10.paid_at__extract_dow AS paid_at__extract_dow + , subq_10.paid_at__extract_doy AS paid_at__extract_doy + , subq_10.booking__ds__day AS booking__ds__day + , subq_10.booking__ds__week AS booking__ds__week + , subq_10.booking__ds__month AS booking__ds__month + , subq_10.booking__ds__quarter AS booking__ds__quarter + , subq_10.booking__ds__year AS booking__ds__year + , subq_10.booking__ds__extract_year AS booking__ds__extract_year + , subq_10.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_10.booking__ds__extract_month AS booking__ds__extract_month + , subq_10.booking__ds__extract_day AS booking__ds__extract_day + , subq_10.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_10.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day AS booking__paid_at__day + , subq_10.booking__paid_at__week AS booking__paid_at__week + , subq_10.booking__paid_at__month AS booking__paid_at__month + , subq_10.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_10.booking__paid_at__year AS booking__paid_at__year + , subq_10.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_10.metric_time__week AS metric_time__week + , subq_10.metric_time__month AS metric_time__month + , subq_10.metric_time__quarter AS metric_time__quarter + , subq_10.metric_time__year AS metric_time__year + , subq_10.metric_time__extract_year AS metric_time__extract_year + , subq_10.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_10.metric_time__extract_month AS metric_time__extract_month + , subq_10.metric_time__extract_day AS metric_time__extract_day + , subq_10.metric_time__extract_dow AS metric_time__extract_dow + , subq_10.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.listing AS listing + , subq_10.guest AS guest + , subq_10.host AS host + , subq_10.booking__listing AS booking__listing + , subq_10.booking__guest AS booking__guest + , subq_10.booking__host AS booking__host + , subq_10.is_instant AS is_instant + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings + , subq_10.instant_bookings AS instant_bookings + , subq_10.booking_value AS booking_value + , subq_10.max_booking_value AS max_booking_value + , subq_10.min_booking_value AS min_booking_value + , subq_10.bookers AS bookers + , subq_10.average_booking_value AS average_booking_value + , subq_10.referred_bookings AS referred_bookings + , subq_10.median_booking_value AS median_booking_value + , subq_10.booking_value_p99 AS booking_value_p99 + , subq_10.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 + subq_12.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + ) subq_11 INNER JOIN ( -- 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 + , 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_9 + ) subq_10 ON ( - subq_1.metric_time__day <= subq_2.metric_time__day + subq_10.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_1.metric_time__day > DATE_ADD('day', -2, subq_2.metric_time__day) + subq_10.metric_time__day > DATE_ADD('day', -2, subq_11.metric_time__day) ) - ) subq_4 - ) subq_5 + ) subq_13 + ) subq_14 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_14.metric_time__day + ) subq_15 ON - subq_7.metric_time__day = subq_6.metric_time__day -) subq_9 + subq_16.metric_time__day = subq_15.metric_time__day +) subq_18 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0_optimized.sql index bd7e2fb6dd..900708f93f 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0_optimized.sql @@ -5,28 +5,28 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_18.ds AS metric_time__day - , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + subq_27.ds AS metric_time__day + , subq_25.bookers AS bookers + FROM ***************************.mf_time_spine subq_27 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures SELECT - subq_13.ds AS metric_time__day - , COUNT(DISTINCT bookings_source_src_28001.guest_id) AS bookers - FROM ***************************.mf_time_spine subq_13 + subq_22.ds AS metric_time__day + , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers + FROM ***************************.mf_time_spine subq_22 INNER JOIN - ***************************.fct_bookings bookings_source_src_28001 + ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28001.ds) <= subq_13.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_22.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28001.ds) > DATE_ADD('day', -2, subq_13.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_22.ds) ) GROUP BY - subq_13.ds - ) subq_16 + subq_22.ds + ) subq_25 ON - subq_18.ds = subq_16.metric_time__day -) subq_19 + subq_27.ds = subq_25.metric_time__day +) subq_28 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 5261b77128..310167637b 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -1,559 +1,559 @@ -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day + subq_25.metric_time__day , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_7.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_15.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_16.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_24.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day - ) subq_6 - ) subq_7 + subq_13.metric_time__day = subq_12.metric_time__day + ) subq_15 + ) subq_16 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.metric_time__day - , subq_14.bookings AS bookings_2_weeks_ago + subq_23.metric_time__day + , subq_23.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_13.metric_time__day - , SUM(subq_13.bookings) AS bookings + subq_22.metric_time__day + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_12.metric_time__day - , subq_12.bookings + subq_21.metric_time__day + , subq_21.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day - , subq_9.ds__week AS ds__week - , subq_9.ds__month AS ds__month - , subq_9.ds__quarter AS ds__quarter - , subq_9.ds__year AS ds__year - , subq_9.ds__extract_year AS ds__extract_year - , subq_9.ds__extract_quarter AS ds__extract_quarter - , subq_9.ds__extract_month AS ds__extract_month - , subq_9.ds__extract_day AS ds__extract_day - , subq_9.ds__extract_dow AS ds__extract_dow - , subq_9.ds__extract_doy AS ds__extract_doy - , subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.paid_at__day AS paid_at__day - , subq_9.paid_at__week AS paid_at__week - , subq_9.paid_at__month AS paid_at__month - , subq_9.paid_at__quarter AS paid_at__quarter - , subq_9.paid_at__year AS paid_at__year - , subq_9.paid_at__extract_year AS paid_at__extract_year - , subq_9.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_9.paid_at__extract_month AS paid_at__extract_month - , subq_9.paid_at__extract_day AS paid_at__extract_day - , subq_9.paid_at__extract_dow AS paid_at__extract_dow - , subq_9.paid_at__extract_doy AS paid_at__extract_doy - , subq_9.booking__ds__day AS booking__ds__day - , subq_9.booking__ds__week AS booking__ds__week - , subq_9.booking__ds__month AS booking__ds__month - , subq_9.booking__ds__quarter AS booking__ds__quarter - , subq_9.booking__ds__year AS booking__ds__year - , subq_9.booking__ds__extract_year AS booking__ds__extract_year - , subq_9.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_9.booking__ds__extract_month AS booking__ds__extract_month - , subq_9.booking__ds__extract_day AS booking__ds__extract_day - , subq_9.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_9.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_9.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_9.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_9.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_9.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_9.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_9.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_9.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_9.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_9.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_9.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_9.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_9.booking__paid_at__day AS booking__paid_at__day - , subq_9.booking__paid_at__week AS booking__paid_at__week - , subq_9.booking__paid_at__month AS booking__paid_at__month - , subq_9.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_9.booking__paid_at__year AS booking__paid_at__year - , subq_9.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_9.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_9.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.listing AS listing - , subq_9.guest AS guest - , subq_9.host AS host - , subq_9.booking__listing AS booking__listing - , subq_9.booking__guest AS booking__guest - , subq_9.booking__host AS booking__host - , subq_9.is_instant AS is_instant - , subq_9.booking__is_instant AS booking__is_instant - , subq_9.bookings AS bookings - , subq_9.instant_bookings AS instant_bookings - , subq_9.booking_value AS booking_value - , subq_9.max_booking_value AS max_booking_value - , subq_9.min_booking_value AS min_booking_value - , subq_9.bookers AS bookers - , subq_9.average_booking_value AS average_booking_value - , subq_9.referred_bookings AS referred_bookings - , subq_9.median_booking_value AS median_booking_value - , subq_9.booking_value_p99 AS booking_value_p99 - , subq_9.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_9.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_9.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + subq_19.metric_time__day AS metric_time__day + , subq_18.ds__day AS ds__day + , subq_18.ds__week AS ds__week + , subq_18.ds__month AS ds__month + , subq_18.ds__quarter AS ds__quarter + , subq_18.ds__year AS ds__year + , subq_18.ds__extract_year AS ds__extract_year + , subq_18.ds__extract_quarter AS ds__extract_quarter + , subq_18.ds__extract_month AS ds__extract_month + , subq_18.ds__extract_day AS ds__extract_day + , subq_18.ds__extract_dow AS ds__extract_dow + , subq_18.ds__extract_doy AS ds__extract_doy + , subq_18.ds_partitioned__day AS ds_partitioned__day + , subq_18.ds_partitioned__week AS ds_partitioned__week + , subq_18.ds_partitioned__month AS ds_partitioned__month + , subq_18.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_18.ds_partitioned__year AS ds_partitioned__year + , subq_18.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_18.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_18.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_18.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_18.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_18.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_18.paid_at__day AS paid_at__day + , subq_18.paid_at__week AS paid_at__week + , subq_18.paid_at__month AS paid_at__month + , subq_18.paid_at__quarter AS paid_at__quarter + , subq_18.paid_at__year AS paid_at__year + , subq_18.paid_at__extract_year AS paid_at__extract_year + , subq_18.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_18.paid_at__extract_month AS paid_at__extract_month + , subq_18.paid_at__extract_day AS paid_at__extract_day + , subq_18.paid_at__extract_dow AS paid_at__extract_dow + , subq_18.paid_at__extract_doy AS paid_at__extract_doy + , subq_18.booking__ds__day AS booking__ds__day + , subq_18.booking__ds__week AS booking__ds__week + , subq_18.booking__ds__month AS booking__ds__month + , subq_18.booking__ds__quarter AS booking__ds__quarter + , subq_18.booking__ds__year AS booking__ds__year + , subq_18.booking__ds__extract_year AS booking__ds__extract_year + , subq_18.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_18.booking__ds__extract_month AS booking__ds__extract_month + , subq_18.booking__ds__extract_day AS booking__ds__extract_day + , subq_18.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_18.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_18.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_18.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_18.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_18.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_18.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_18.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_18.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_18.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_18.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_18.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_18.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_18.booking__paid_at__day AS booking__paid_at__day + , subq_18.booking__paid_at__week AS booking__paid_at__week + , subq_18.booking__paid_at__month AS booking__paid_at__month + , subq_18.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_18.booking__paid_at__year AS booking__paid_at__year + , subq_18.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_18.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_18.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_18.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_18.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_18.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_18.listing AS listing + , subq_18.guest AS guest + , subq_18.host AS host + , subq_18.booking__listing AS booking__listing + , subq_18.booking__guest AS booking__guest + , subq_18.booking__host AS booking__host + , subq_18.is_instant AS is_instant + , subq_18.booking__is_instant AS booking__is_instant + , subq_18.bookings AS bookings + , subq_18.instant_bookings AS instant_bookings + , subq_18.booking_value AS booking_value + , subq_18.max_booking_value AS max_booking_value + , subq_18.min_booking_value AS min_booking_value + , subq_18.bookers AS bookers + , subq_18.average_booking_value AS average_booking_value + , subq_18.referred_bookings AS referred_bookings + , subq_18.median_booking_value AS median_booking_value + , subq_18.booking_value_p99 AS booking_value_p99 + , subq_18.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_18.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_18.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_11 - ) subq_10 + subq_20.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + ) subq_19 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.paid_at__day - , subq_8.paid_at__week - , subq_8.paid_at__month - , subq_8.paid_at__quarter - , subq_8.paid_at__year - , subq_8.paid_at__extract_year - , subq_8.paid_at__extract_quarter - , subq_8.paid_at__extract_month - , subq_8.paid_at__extract_day - , subq_8.paid_at__extract_dow - , subq_8.paid_at__extract_doy - , subq_8.booking__ds__day - , subq_8.booking__ds__week - , subq_8.booking__ds__month - , subq_8.booking__ds__quarter - , subq_8.booking__ds__year - , subq_8.booking__ds__extract_year - , subq_8.booking__ds__extract_quarter - , subq_8.booking__ds__extract_month - , subq_8.booking__ds__extract_day - , subq_8.booking__ds__extract_dow - , subq_8.booking__ds__extract_doy - , subq_8.booking__ds_partitioned__day - , subq_8.booking__ds_partitioned__week - , subq_8.booking__ds_partitioned__month - , subq_8.booking__ds_partitioned__quarter - , subq_8.booking__ds_partitioned__year - , subq_8.booking__ds_partitioned__extract_year - , subq_8.booking__ds_partitioned__extract_quarter - , subq_8.booking__ds_partitioned__extract_month - , subq_8.booking__ds_partitioned__extract_day - , subq_8.booking__ds_partitioned__extract_dow - , subq_8.booking__ds_partitioned__extract_doy - , subq_8.booking__paid_at__day - , subq_8.booking__paid_at__week - , subq_8.booking__paid_at__month - , subq_8.booking__paid_at__quarter - , subq_8.booking__paid_at__year - , subq_8.booking__paid_at__extract_year - , subq_8.booking__paid_at__extract_quarter - , subq_8.booking__paid_at__extract_month - , subq_8.booking__paid_at__extract_day - , subq_8.booking__paid_at__extract_dow - , subq_8.booking__paid_at__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.guest - , subq_8.host - , subq_8.booking__listing - , subq_8.booking__guest - , subq_8.booking__host - , subq_8.is_instant - , subq_8.booking__is_instant - , subq_8.bookings - , subq_8.instant_bookings - , subq_8.booking_value - , subq_8.max_booking_value - , subq_8.min_booking_value - , subq_8.bookers - , subq_8.average_booking_value - , subq_8.referred_bookings - , subq_8.median_booking_value - , subq_8.booking_value_p99 - , subq_8.discrete_booking_value_p99 - , subq_8.approximate_continuous_booking_value_p99 - , subq_8.approximate_discrete_booking_value_p99 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.ds_partitioned__day + , subq_17.ds_partitioned__week + , subq_17.ds_partitioned__month + , subq_17.ds_partitioned__quarter + , subq_17.ds_partitioned__year + , subq_17.ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy + , subq_17.paid_at__day + , subq_17.paid_at__week + , subq_17.paid_at__month + , subq_17.paid_at__quarter + , subq_17.paid_at__year + , subq_17.paid_at__extract_year + , subq_17.paid_at__extract_quarter + , subq_17.paid_at__extract_month + , subq_17.paid_at__extract_day + , subq_17.paid_at__extract_dow + , subq_17.paid_at__extract_doy + , subq_17.booking__ds__day + , subq_17.booking__ds__week + , subq_17.booking__ds__month + , subq_17.booking__ds__quarter + , subq_17.booking__ds__year + , subq_17.booking__ds__extract_year + , subq_17.booking__ds__extract_quarter + , subq_17.booking__ds__extract_month + , subq_17.booking__ds__extract_day + , subq_17.booking__ds__extract_dow + , subq_17.booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day + , subq_17.booking__paid_at__week + , subq_17.booking__paid_at__month + , subq_17.booking__paid_at__quarter + , subq_17.booking__paid_at__year + , subq_17.booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.guest + , subq_17.host + , subq_17.booking__listing + , subq_17.booking__guest + , subq_17.booking__host + , subq_17.is_instant + , subq_17.booking__is_instant + , subq_17.bookings + , subq_17.instant_bookings + , subq_17.booking_value + , subq_17.max_booking_value + , subq_17.min_booking_value + , subq_17.bookers + , subq_17.average_booking_value + , subq_17.referred_bookings + , subq_17.median_booking_value + , subq_17.booking_value_p99 + , subq_17.discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_8 - ) subq_9 + , 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_17 + ) subq_18 ON - DATE_ADD('day', -14, subq_10.metric_time__day) = subq_9.metric_time__day - ) subq_12 - ) subq_13 + DATE_ADD('day', -14, subq_19.metric_time__day) = subq_18.metric_time__day + ) subq_21 + ) subq_22 GROUP BY - subq_13.metric_time__day - ) subq_14 - ) subq_15 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - subq_7.metric_time__day = subq_15.metric_time__day + subq_16.metric_time__day = subq_24.metric_time__day GROUP BY - COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) -) subq_16 + COALESCE(subq_16.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index aa46fba2f7..62169c80dc 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , COALESCE(MAX(subq_24.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , MAX(subq_32.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) AS metric_time__day + , COALESCE(MAX(subq_33.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , MAX(subq_41.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -16,9 +16,9 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + subq_31.ds AS metric_time__day + , subq_29.bookings AS bookings + FROM ***************************.mf_time_spine subq_31 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -31,39 +31,39 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_19 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_28 GROUP BY metric_time__day - ) subq_20 + ) subq_29 ON - subq_22.ds = subq_20.metric_time__day - ) subq_23 - ) subq_24 + subq_31.ds = subq_29.metric_time__day + ) subq_32 + ) subq_33 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day - , SUM(subq_26.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_28 + subq_37.ds AS metric_time__day + , SUM(subq_35.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_26 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_35 ON - DATE_ADD('day', -14, subq_28.ds) = subq_26.metric_time__day + DATE_ADD('day', -14, subq_37.ds) = subq_35.metric_time__day GROUP BY - subq_28.ds - ) subq_32 + subq_37.ds + ) subq_41 ON - subq_24.metric_time__day = subq_32.metric_time__day + subq_33.metric_time__day = subq_41.metric_time__day GROUP BY - COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_33.metric_time__day, subq_41.metric_time__day) +) subq_42 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0.sql index 38e51fc60a..7e15c08a5f 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__day + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql index 88bc47bb27..25b6898e3d 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings - FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings + FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -20,11 +20,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day - ) subq_10 + ) subq_19 ON - subq_12.ds = subq_10.metric_time__day -) subq_13 + subq_21.ds = subq_19.metric_time__day +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_month__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_month__plan0.sql index d4a2a22ecf..c6c8e17826 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_month__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_month__plan0.sql @@ -1,229 +1,229 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__month - , COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + subq_15.metric_time__month + , COALESCE(subq_15.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__month AS metric_time__month - , subq_3.bookings AS bookings + subq_13.metric_time__month AS metric_time__month + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_5.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_5 + DATE_TRUNC('month', subq_14.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_14 GROUP BY - DATE_TRUNC('month', subq_5.ds) - ) subq_4 + DATE_TRUNC('month', subq_14.ds) + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__month - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__month + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__month'] SELECT - subq_1.metric_time__month - , subq_1.bookings + subq_10.metric_time__month + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__month - ) subq_3 + subq_11.metric_time__month + ) subq_12 ON - subq_4.metric_time__month = subq_3.metric_time__month -) subq_6 + subq_13.metric_time__month = subq_12.metric_time__month +) subq_15 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_month__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_month__plan0_optimized.sql index 3f0b900958..15f2f4275e 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_month__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_month__plan0_optimized.sql @@ -5,16 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_11.metric_time__month AS metric_time__month - , subq_10.bookings AS bookings + subq_20.metric_time__month AS metric_time__month + , subq_19.bookings AS bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_12 + FROM ***************************.mf_time_spine subq_21 GROUP BY DATE_TRUNC('month', ds) - ) subq_11 + ) subq_20 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -27,11 +27,11 @@ FROM ( SELECT DATE_TRUNC('month', ds) AS metric_time__month , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__month - ) subq_10 + ) subq_19 ON - subq_11.metric_time__month = subq_10.metric_time__month -) subq_13 + subq_20.metric_time__month = subq_19.metric_time__month +) subq_22 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql index 574c95966c..21b41504d8 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__is_instant - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__is_instant + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__is_instant - , SUM(subq_2.bookings) AS bookings + subq_11.booking__is_instant + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_1.booking__is_instant - , subq_1.bookings + subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__is_instant -) subq_3 + subq_11.booking__is_instant +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql index 3cb5d4ac8a..820fbf315b 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_categorical_dimension__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__is_instant -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql index 85d5ae6283..e100b4ae4c 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_non_metric_time__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.booking__paid_at__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 + subq_12.booking__paid_at__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - subq_2.booking__paid_at__day - , SUM(subq_2.bookings) AS bookings + subq_11.booking__paid_at__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__paid_at__day'] SELECT - subq_1.booking__paid_at__day - , subq_1.bookings + subq_10.booking__paid_at__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.booking__paid_at__day -) subq_3 + subq_11.booking__paid_at__day +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql index 9feb4f2769..6a499adb15 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_with_non_metric_time__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC('day', paid_at) AS booking__paid_at__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY booking__paid_at__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_without_time_spine__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_without_time_spine__plan0.sql index 780cbf9c9e..60281e85dc 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_without_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_without_time_spine__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine + subq_12.metric_time__day + , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0_without_time_spine FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day -) subq_3 + subq_11.metric_time__day +) subq_12 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql index 65ce5f540b..5ef604d794 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_without_time_spine__plan0_optimized.sql @@ -14,8 +14,8 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_15 GROUP BY metric_time__day -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql index e774fe9832..d095849dd9 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__extract_dow + subq_22.metric_time__extract_dow , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__extract_dow, subq_21.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__extract_dow - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__extract_dow - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__extract_dow + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__extract_dow - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__extract_dow + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_9.metric_time__extract_dow - , subq_9.bookings + subq_18.metric_time__extract_dow + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - IF(EXTRACT(dayofweek FROM subq_7.metric_time__day) = 1, 7, EXTRACT(dayofweek FROM subq_7.metric_time__day) - 1) AS metric_time__extract_dow - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + IF(EXTRACT(dayofweek FROM subq_16.metric_time__day) = 1, 7, EXTRACT(dayofweek FROM subq_16.metric_time__day) - 1) AS metric_time__extract_dow + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_SUB(CAST(subq_7.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATE_SUB(CAST(subq_16.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY metric_time__extract_dow - ) subq_11 - ) subq_12 + ) subq_20 + ) subq_21 ON - subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow + subq_13.metric_time__extract_dow = subq_21.metric_time__extract_dow GROUP BY metric_time__extract_dow -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql index 7a71bf9f8d..8cd1e0feda 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__extract_dow, subq_35.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT IF(EXTRACT(dayofweek FROM ds) = 1, 7, EXTRACT(dayofweek FROM ds) - 1) AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__extract_dow - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - IF(EXTRACT(dayofweek FROM subq_22.ds) = 1, 7, EXTRACT(dayofweek FROM subq_22.ds) - 1) AS metric_time__extract_dow - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + IF(EXTRACT(dayofweek FROM subq_31.ds) = 1, 7, EXTRACT(dayofweek FROM subq_31.ds) - 1) AS metric_time__extract_dow + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_SUB(CAST(subq_22.ds AS DATETIME), INTERVAL 14 day) = subq_20.metric_time__day + DATE_SUB(CAST(subq_31.ds AS DATETIME), INTERVAL 14 day) = subq_29.metric_time__day GROUP BY metric_time__extract_dow - ) subq_26 + ) subq_35 ON - subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow + subq_27.metric_time__extract_dow = subq_35.metric_time__extract_dow GROUP BY metric_time__extract_dow -) subq_27 +) subq_36 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_date_part__plan0.sql index 205d20c5ea..2e8457acdc 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_date_part__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__extract_dow -) subq_3 +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_date_part__plan0_optimized.sql index 68fb5d4b63..acdb0f3d2f 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_date_part__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT IF(EXTRACT(dayofweek FROM ds) = 1, 7, EXTRACT(dayofweek FROM ds) - 1) AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_dow diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_multiple_date_parts__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_multiple_date_parts__plan0.sql index d53a60bef4..6473570e07 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_multiple_date_parts__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_multiple_date_parts__plan0.sql @@ -1,22 +1,22 @@ -- Compute Metrics via Expressions SELECT - 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.bookings + subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_year - , subq_2.metric_time__extract_quarter - , subq_2.metric_time__extract_month - , subq_2.metric_time__extract_day - , subq_2.metric_time__extract_dow - , subq_2.metric_time__extract_doy - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: [ -- 'bookings', @@ -28,209 +28,209 @@ FROM ( -- 'metric_time__extract_year', -- ] SELECT - subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.bookings + subq_10.metric_time__extract_year + , subq_10.metric_time__extract_quarter + , subq_10.metric_time__extract_month + , subq_10.metric_time__extract_day + , subq_10.metric_time__extract_dow + , subq_10.metric_time__extract_doy + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__extract_year , metric_time__extract_quarter @@ -238,4 +238,4 @@ FROM ( , metric_time__extract_day , metric_time__extract_dow , metric_time__extract_doy -) subq_3 +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_multiple_date_parts__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_multiple_date_parts__plan0_optimized.sql index 8af84752d8..e870e623b2 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_multiple_date_parts__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_query_with_multiple_date_parts__plan0_optimized.sql @@ -28,8 +28,8 @@ FROM ( , IF(EXTRACT(dayofweek FROM ds) = 1, 7, EXTRACT(dayofweek FROM ds) - 1) AS metric_time__extract_dow , EXTRACT(dayofyear FROM ds) AS metric_time__extract_doy , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_year , metric_time__extract_quarter diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql index 17972106c0..3cf4147b3b 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__extract_dow + subq_22.metric_time__extract_dow , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__extract_dow, subq_21.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_dow - ) subq_3 - ) subq_4 + subq_11.metric_time__extract_dow + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__extract_dow - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__extract_dow + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__extract_dow - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__extract_dow + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_9.metric_time__extract_dow - , subq_9.bookings + subq_18.metric_time__extract_dow + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - EXTRACT(DAYOFWEEK_ISO FROM subq_7.metric_time__day) AS metric_time__extract_dow - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + EXTRACT(DAYOFWEEK_ISO FROM subq_16.metric_time__day) AS metric_time__extract_dow + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATEADD(day, -14, subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATEADD(day, -14, subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__extract_dow - ) subq_11 - ) subq_12 + subq_19.metric_time__extract_dow + ) subq_20 + ) subq_21 ON - subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow + subq_13.metric_time__extract_dow = subq_21.metric_time__extract_dow GROUP BY - COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) -) subq_13 + COALESCE(subq_13.metric_time__extract_dow, subq_21.metric_time__extract_dow) +) subq_22 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql index 2ba3f9f227..7eeaa65aa8 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__extract_dow, subq_35.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT EXTRACT(DAYOFWEEK_ISO FROM ds) AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__extract_dow - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - EXTRACT(DAYOFWEEK_ISO FROM subq_22.ds) AS metric_time__extract_dow - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + EXTRACT(DAYOFWEEK_ISO FROM subq_31.ds) AS metric_time__extract_dow + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_31.ds) = subq_29.metric_time__day GROUP BY - EXTRACT(DAYOFWEEK_ISO FROM subq_22.ds) - ) subq_26 + EXTRACT(DAYOFWEEK_ISO FROM subq_31.ds) + ) subq_35 ON - subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow + subq_27.metric_time__extract_dow = subq_35.metric_time__extract_dow GROUP BY - COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) -) subq_27 + COALESCE(subq_27.metric_time__extract_dow, subq_35.metric_time__extract_dow) +) subq_36 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_date_part__plan0.sql index d5afd6f550..24357de4e3 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_date_part__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_dow -) subq_3 + subq_11.metric_time__extract_dow +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_date_part__plan0_optimized.sql index f89ef9f07c..0374bd26e4 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_date_part__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT EXTRACT(DAYOFWEEK_ISO FROM ds) AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_dow diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_multiple_date_parts__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_multiple_date_parts__plan0.sql index 5bac185c61..a1f15b118d 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_multiple_date_parts__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_multiple_date_parts__plan0.sql @@ -1,22 +1,22 @@ -- Compute Metrics via Expressions SELECT - 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.bookings + subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_year - , subq_2.metric_time__extract_quarter - , subq_2.metric_time__extract_month - , subq_2.metric_time__extract_day - , subq_2.metric_time__extract_dow - , subq_2.metric_time__extract_doy - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: [ -- 'bookings', @@ -28,214 +28,214 @@ FROM ( -- 'metric_time__extract_year', -- ] SELECT - subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.bookings + subq_10.metric_time__extract_year + , subq_10.metric_time__extract_quarter + , subq_10.metric_time__extract_month + , subq_10.metric_time__extract_day + , subq_10.metric_time__extract_dow + , subq_10.metric_time__extract_doy + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_year - , subq_2.metric_time__extract_quarter - , subq_2.metric_time__extract_month - , subq_2.metric_time__extract_day - , subq_2.metric_time__extract_dow - , subq_2.metric_time__extract_doy -) subq_3 + subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_multiple_date_parts__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_multiple_date_parts__plan0_optimized.sql index bf07b1b27b..715c1b0ecb 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_multiple_date_parts__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_query_with_multiple_date_parts__plan0_optimized.sql @@ -28,8 +28,8 @@ FROM ( , EXTRACT(DAYOFWEEK_ISO FROM ds) AS metric_time__extract_dow , EXTRACT(doy FROM ds) AS metric_time__extract_doy , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_year , metric_time__extract_quarter diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql index a0763ab3b5..58bdab29b1 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__extract_dow + subq_22.metric_time__extract_dow , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__extract_dow, subq_21.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_dow - ) subq_3 - ) subq_4 + subq_11.metric_time__extract_dow + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__extract_dow - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__extract_dow + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__extract_dow - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__extract_dow + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_9.metric_time__extract_dow - , subq_9.bookings + subq_18.metric_time__extract_dow + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - EXTRACT(isodow FROM subq_7.metric_time__day) AS metric_time__extract_dow - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + EXTRACT(isodow FROM subq_16.metric_time__day) AS metric_time__extract_dow + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - subq_7.metric_time__day - INTERVAL 14 day = subq_6.metric_time__day - ) subq_9 - ) subq_10 + subq_16.metric_time__day - INTERVAL 14 day = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__extract_dow - ) subq_11 - ) subq_12 + subq_19.metric_time__extract_dow + ) subq_20 + ) subq_21 ON - subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow + subq_13.metric_time__extract_dow = subq_21.metric_time__extract_dow GROUP BY - COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) -) subq_13 + COALESCE(subq_13.metric_time__extract_dow, subq_21.metric_time__extract_dow) +) subq_22 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0_optimized.sql index ab923b3448..bada4904c6 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__extract_dow, subq_35.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT EXTRACT(isodow FROM ds) AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__extract_dow - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - EXTRACT(isodow FROM subq_22.ds) AS metric_time__extract_dow - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + EXTRACT(isodow FROM subq_31.ds) AS metric_time__extract_dow + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - subq_22.ds - INTERVAL 14 day = subq_20.metric_time__day + subq_31.ds - INTERVAL 14 day = subq_29.metric_time__day GROUP BY - EXTRACT(isodow FROM subq_22.ds) - ) subq_26 + EXTRACT(isodow FROM subq_31.ds) + ) subq_35 ON - subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow + subq_27.metric_time__extract_dow = subq_35.metric_time__extract_dow GROUP BY - COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) -) subq_27 + COALESCE(subq_27.metric_time__extract_dow, subq_35.metric_time__extract_dow) +) subq_36 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_date_part__plan0.sql index 09c76b3539..b0e96b3337 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_date_part__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_dow -) subq_3 + subq_11.metric_time__extract_dow +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_date_part__plan0_optimized.sql index 2aa1237558..1562428008 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_date_part__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT EXTRACT(isodow FROM ds) AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_dow diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_multiple_date_parts__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_multiple_date_parts__plan0.sql index ccafd85787..2b19ef82f3 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_multiple_date_parts__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_multiple_date_parts__plan0.sql @@ -1,22 +1,22 @@ -- Compute Metrics via Expressions SELECT - 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.bookings + subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_year - , subq_2.metric_time__extract_quarter - , subq_2.metric_time__extract_month - , subq_2.metric_time__extract_day - , subq_2.metric_time__extract_dow - , subq_2.metric_time__extract_doy - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: [ -- 'bookings', @@ -28,214 +28,214 @@ FROM ( -- 'metric_time__extract_year', -- ] SELECT - subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.bookings + subq_10.metric_time__extract_year + , subq_10.metric_time__extract_quarter + , subq_10.metric_time__extract_month + , subq_10.metric_time__extract_day + , subq_10.metric_time__extract_dow + , subq_10.metric_time__extract_doy + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_year - , subq_2.metric_time__extract_quarter - , subq_2.metric_time__extract_month - , subq_2.metric_time__extract_day - , subq_2.metric_time__extract_dow - , subq_2.metric_time__extract_doy -) subq_3 + subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_multiple_date_parts__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_multiple_date_parts__plan0_optimized.sql index e0533766ca..c857a30304 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_multiple_date_parts__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_query_with_multiple_date_parts__plan0_optimized.sql @@ -28,8 +28,8 @@ FROM ( , EXTRACT(isodow FROM ds) AS metric_time__extract_dow , EXTRACT(doy FROM ds) AS metric_time__extract_doy , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_year , metric_time__extract_quarter diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql index 27c00f18a6..2f9471b666 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__extract_dow + subq_22.metric_time__extract_dow , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__extract_dow, subq_21.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_dow - ) subq_3 - ) subq_4 + subq_11.metric_time__extract_dow + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__extract_dow - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__extract_dow + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__extract_dow - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__extract_dow + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_9.metric_time__extract_dow - , subq_9.bookings + subq_18.metric_time__extract_dow + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - EXTRACT(isodow FROM subq_7.metric_time__day) AS metric_time__extract_dow - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + EXTRACT(isodow FROM subq_16.metric_time__day) AS metric_time__extract_dow + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - subq_7.metric_time__day - MAKE_INTERVAL(days => 14) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + subq_16.metric_time__day - MAKE_INTERVAL(days => 14) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__extract_dow - ) subq_11 - ) subq_12 + subq_19.metric_time__extract_dow + ) subq_20 + ) subq_21 ON - subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow + subq_13.metric_time__extract_dow = subq_21.metric_time__extract_dow GROUP BY - COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) -) subq_13 + COALESCE(subq_13.metric_time__extract_dow, subq_21.metric_time__extract_dow) +) subq_22 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql index c364c376c4..4dfb752678 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__extract_dow, subq_35.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT EXTRACT(isodow FROM ds) AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__extract_dow - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - EXTRACT(isodow FROM subq_22.ds) AS metric_time__extract_dow - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + EXTRACT(isodow FROM subq_31.ds) AS metric_time__extract_dow + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - subq_22.ds - MAKE_INTERVAL(days => 14) = subq_20.metric_time__day + subq_31.ds - MAKE_INTERVAL(days => 14) = subq_29.metric_time__day GROUP BY - EXTRACT(isodow FROM subq_22.ds) - ) subq_26 + EXTRACT(isodow FROM subq_31.ds) + ) subq_35 ON - subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow + subq_27.metric_time__extract_dow = subq_35.metric_time__extract_dow GROUP BY - COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) -) subq_27 + COALESCE(subq_27.metric_time__extract_dow, subq_35.metric_time__extract_dow) +) subq_36 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_date_part__plan0.sql index 09c76b3539..b0e96b3337 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_date_part__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_dow -) subq_3 + subq_11.metric_time__extract_dow +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_date_part__plan0_optimized.sql index 2aa1237558..1562428008 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_date_part__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT EXTRACT(isodow FROM ds) AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_dow diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_multiple_date_parts__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_multiple_date_parts__plan0.sql index ccafd85787..2b19ef82f3 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_multiple_date_parts__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_multiple_date_parts__plan0.sql @@ -1,22 +1,22 @@ -- Compute Metrics via Expressions SELECT - 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.bookings + subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_year - , subq_2.metric_time__extract_quarter - , subq_2.metric_time__extract_month - , subq_2.metric_time__extract_day - , subq_2.metric_time__extract_dow - , subq_2.metric_time__extract_doy - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: [ -- 'bookings', @@ -28,214 +28,214 @@ FROM ( -- 'metric_time__extract_year', -- ] SELECT - subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.bookings + subq_10.metric_time__extract_year + , subq_10.metric_time__extract_quarter + , subq_10.metric_time__extract_month + , subq_10.metric_time__extract_day + , subq_10.metric_time__extract_dow + , subq_10.metric_time__extract_doy + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_year - , subq_2.metric_time__extract_quarter - , subq_2.metric_time__extract_month - , subq_2.metric_time__extract_day - , subq_2.metric_time__extract_dow - , subq_2.metric_time__extract_doy -) subq_3 + subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_multiple_date_parts__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_multiple_date_parts__plan0_optimized.sql index e0533766ca..c857a30304 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_multiple_date_parts__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_query_with_multiple_date_parts__plan0_optimized.sql @@ -28,8 +28,8 @@ FROM ( , EXTRACT(isodow FROM ds) AS metric_time__extract_dow , EXTRACT(doy FROM ds) AS metric_time__extract_doy , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_year , metric_time__extract_quarter diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql index d17a2db062..10314fbd88 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__extract_dow + subq_22.metric_time__extract_dow , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__extract_dow, subq_21.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_dow - ) subq_3 - ) subq_4 + subq_11.metric_time__extract_dow + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__extract_dow - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__extract_dow + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__extract_dow - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__extract_dow + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_9.metric_time__extract_dow - , subq_9.bookings + subq_18.metric_time__extract_dow + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - CASE WHEN EXTRACT(dow FROM subq_7.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_7.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_7.metric_time__day) END AS metric_time__extract_dow - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + CASE WHEN EXTRACT(dow FROM subq_16.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_16.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_16.metric_time__day) END AS metric_time__extract_dow + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATEADD(day, -14, subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATEADD(day, -14, subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__extract_dow - ) subq_11 - ) subq_12 + subq_19.metric_time__extract_dow + ) subq_20 + ) subq_21 ON - subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow + subq_13.metric_time__extract_dow = subq_21.metric_time__extract_dow GROUP BY - COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) -) subq_13 + COALESCE(subq_13.metric_time__extract_dow, subq_21.metric_time__extract_dow) +) subq_22 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql index 3b69bcb10d..2cfa43d886 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__extract_dow, subq_35.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT CASE WHEN EXTRACT(dow FROM ds) = 0 THEN EXTRACT(dow FROM ds) + 7 ELSE EXTRACT(dow FROM ds) END AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__extract_dow - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - CASE WHEN EXTRACT(dow FROM subq_22.ds) = 0 THEN EXTRACT(dow FROM subq_22.ds) + 7 ELSE EXTRACT(dow FROM subq_22.ds) END AS metric_time__extract_dow - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + CASE WHEN EXTRACT(dow FROM subq_31.ds) = 0 THEN EXTRACT(dow FROM subq_31.ds) + 7 ELSE EXTRACT(dow FROM subq_31.ds) END AS metric_time__extract_dow + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_31.ds) = subq_29.metric_time__day GROUP BY - CASE WHEN EXTRACT(dow FROM subq_22.ds) = 0 THEN EXTRACT(dow FROM subq_22.ds) + 7 ELSE EXTRACT(dow FROM subq_22.ds) END - ) subq_26 + CASE WHEN EXTRACT(dow FROM subq_31.ds) = 0 THEN EXTRACT(dow FROM subq_31.ds) + 7 ELSE EXTRACT(dow FROM subq_31.ds) END + ) subq_35 ON - subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow + subq_27.metric_time__extract_dow = subq_35.metric_time__extract_dow GROUP BY - COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) -) subq_27 + COALESCE(subq_27.metric_time__extract_dow, subq_35.metric_time__extract_dow) +) subq_36 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_date_part__plan0.sql index a277c4d690..6538a108ee 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_date_part__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_dow -) subq_3 + subq_11.metric_time__extract_dow +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_date_part__plan0_optimized.sql index 885fd8ff54..a7f8f48632 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_date_part__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT CASE WHEN EXTRACT(dow FROM ds) = 0 THEN EXTRACT(dow FROM ds) + 7 ELSE EXTRACT(dow FROM ds) END AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_dow diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_multiple_date_parts__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_multiple_date_parts__plan0.sql index d1f3180d24..ff6f09478f 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_multiple_date_parts__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_multiple_date_parts__plan0.sql @@ -1,22 +1,22 @@ -- Compute Metrics via Expressions SELECT - 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.bookings + subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_year - , subq_2.metric_time__extract_quarter - , subq_2.metric_time__extract_month - , subq_2.metric_time__extract_day - , subq_2.metric_time__extract_dow - , subq_2.metric_time__extract_doy - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: [ -- 'bookings', @@ -28,214 +28,214 @@ FROM ( -- 'metric_time__extract_year', -- ] SELECT - subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.bookings + subq_10.metric_time__extract_year + , subq_10.metric_time__extract_quarter + , subq_10.metric_time__extract_month + , subq_10.metric_time__extract_day + , subq_10.metric_time__extract_dow + , subq_10.metric_time__extract_doy + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_year - , subq_2.metric_time__extract_quarter - , subq_2.metric_time__extract_month - , subq_2.metric_time__extract_day - , subq_2.metric_time__extract_dow - , subq_2.metric_time__extract_doy -) subq_3 + subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_multiple_date_parts__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_multiple_date_parts__plan0_optimized.sql index 91c98c89ad..3bed467e35 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_multiple_date_parts__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_query_with_multiple_date_parts__plan0_optimized.sql @@ -28,8 +28,8 @@ FROM ( , CASE WHEN EXTRACT(dow FROM ds) = 0 THEN EXTRACT(dow FROM ds) + 7 ELSE EXTRACT(dow FROM ds) END AS metric_time__extract_dow , EXTRACT(doy FROM ds) AS metric_time__extract_doy , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_year , metric_time__extract_quarter diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql index dfd3dcb20b..daabfea294 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__extract_dow + subq_22.metric_time__extract_dow , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__extract_dow, subq_21.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_dow - ) subq_3 - ) subq_4 + subq_11.metric_time__extract_dow + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__extract_dow - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__extract_dow + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__extract_dow - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__extract_dow + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_9.metric_time__extract_dow - , subq_9.bookings + subq_18.metric_time__extract_dow + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - EXTRACT(dayofweekiso FROM subq_7.metric_time__day) AS metric_time__extract_dow - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + EXTRACT(dayofweekiso FROM subq_16.metric_time__day) AS metric_time__extract_dow + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATEADD(day, -14, subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATEADD(day, -14, subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__extract_dow - ) subq_11 - ) subq_12 + subq_19.metric_time__extract_dow + ) subq_20 + ) subq_21 ON - subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow + subq_13.metric_time__extract_dow = subq_21.metric_time__extract_dow GROUP BY - COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) -) subq_13 + COALESCE(subq_13.metric_time__extract_dow, subq_21.metric_time__extract_dow) +) subq_22 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql index 17dda92b0e..c12c40f680 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__extract_dow, subq_35.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT EXTRACT(dayofweekiso FROM ds) AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__extract_dow - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - EXTRACT(dayofweekiso FROM subq_22.ds) AS metric_time__extract_dow - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + EXTRACT(dayofweekiso FROM subq_31.ds) AS metric_time__extract_dow + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_31.ds) = subq_29.metric_time__day GROUP BY - EXTRACT(dayofweekiso FROM subq_22.ds) - ) subq_26 + EXTRACT(dayofweekiso FROM subq_31.ds) + ) subq_35 ON - subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow + subq_27.metric_time__extract_dow = subq_35.metric_time__extract_dow GROUP BY - COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) -) subq_27 + COALESCE(subq_27.metric_time__extract_dow, subq_35.metric_time__extract_dow) +) subq_36 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_date_part__plan0.sql index a8201ea29c..6bd5c513a4 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_date_part__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_dow -) subq_3 + subq_11.metric_time__extract_dow +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_date_part__plan0_optimized.sql index 1ef4b4a4e7..db9b64f7f4 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_date_part__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT EXTRACT(dayofweekiso FROM ds) AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_dow diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_multiple_date_parts__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_multiple_date_parts__plan0.sql index 6b1fb9c4ca..262eb36f70 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_multiple_date_parts__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_multiple_date_parts__plan0.sql @@ -1,22 +1,22 @@ -- Compute Metrics via Expressions SELECT - 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.bookings + subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_year - , subq_2.metric_time__extract_quarter - , subq_2.metric_time__extract_month - , subq_2.metric_time__extract_day - , subq_2.metric_time__extract_dow - , subq_2.metric_time__extract_doy - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: [ -- 'bookings', @@ -28,214 +28,214 @@ FROM ( -- 'metric_time__extract_year', -- ] SELECT - subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.bookings + subq_10.metric_time__extract_year + , subq_10.metric_time__extract_quarter + , subq_10.metric_time__extract_month + , subq_10.metric_time__extract_day + , subq_10.metric_time__extract_dow + , subq_10.metric_time__extract_doy + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_year - , subq_2.metric_time__extract_quarter - , subq_2.metric_time__extract_month - , subq_2.metric_time__extract_day - , subq_2.metric_time__extract_dow - , subq_2.metric_time__extract_doy -) subq_3 + subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_multiple_date_parts__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_multiple_date_parts__plan0_optimized.sql index 09d874e549..3543c0ba7b 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_multiple_date_parts__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_query_with_multiple_date_parts__plan0_optimized.sql @@ -28,8 +28,8 @@ FROM ( , EXTRACT(dayofweekiso FROM ds) AS metric_time__extract_dow , EXTRACT(doy FROM ds) AS metric_time__extract_doy , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_year , metric_time__extract_quarter diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0.sql index c5e61969ff..3bf28d3814 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0.sql @@ -1,545 +1,545 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__extract_dow + subq_22.metric_time__extract_dow , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_4.bookings) AS bookings - , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_13.metric_time__extract_dow, subq_21.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_13.bookings) AS bookings + , MAX(subq_21.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_dow - ) subq_3 - ) subq_4 + subq_11.metric_time__extract_dow + ) subq_12 + ) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_11.metric_time__extract_dow - , subq_11.bookings AS bookings_2_weeks_ago + subq_20.metric_time__extract_dow + , subq_20.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_10.metric_time__extract_dow - , SUM(subq_10.bookings) AS bookings + subq_19.metric_time__extract_dow + , SUM(subq_19.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_9.metric_time__extract_dow - , subq_9.bookings + subq_18.metric_time__extract_dow + , subq_18.bookings FROM ( -- Join to Time Spine Dataset SELECT - EXTRACT(DAY_OF_WEEK FROM subq_7.metric_time__day) AS metric_time__extract_dow - , subq_6.ds__day AS ds__day - , subq_6.ds__week AS ds__week - , subq_6.ds__month AS ds__month - , subq_6.ds__quarter AS ds__quarter - , subq_6.ds__year AS ds__year - , subq_6.ds__extract_year AS ds__extract_year - , subq_6.ds__extract_quarter AS ds__extract_quarter - , subq_6.ds__extract_month AS ds__extract_month - , subq_6.ds__extract_day AS ds__extract_day - , subq_6.ds__extract_dow AS ds__extract_dow - , subq_6.ds__extract_doy AS ds__extract_doy - , subq_6.ds_partitioned__day AS ds_partitioned__day - , subq_6.ds_partitioned__week AS ds_partitioned__week - , subq_6.ds_partitioned__month AS ds_partitioned__month - , subq_6.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_6.ds_partitioned__year AS ds_partitioned__year - , subq_6.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_6.paid_at__day AS paid_at__day - , subq_6.paid_at__week AS paid_at__week - , subq_6.paid_at__month AS paid_at__month - , subq_6.paid_at__quarter AS paid_at__quarter - , subq_6.paid_at__year AS paid_at__year - , subq_6.paid_at__extract_year AS paid_at__extract_year - , subq_6.paid_at__extract_quarter AS paid_at__extract_quarter - , subq_6.paid_at__extract_month AS paid_at__extract_month - , subq_6.paid_at__extract_day AS paid_at__extract_day - , subq_6.paid_at__extract_dow AS paid_at__extract_dow - , subq_6.paid_at__extract_doy AS paid_at__extract_doy - , subq_6.booking__ds__day AS booking__ds__day - , subq_6.booking__ds__week AS booking__ds__week - , subq_6.booking__ds__month AS booking__ds__month - , subq_6.booking__ds__quarter AS booking__ds__quarter - , subq_6.booking__ds__year AS booking__ds__year - , subq_6.booking__ds__extract_year AS booking__ds__extract_year - , subq_6.booking__ds__extract_quarter AS booking__ds__extract_quarter - , subq_6.booking__ds__extract_month AS booking__ds__extract_month - , subq_6.booking__ds__extract_day AS booking__ds__extract_day - , subq_6.booking__ds__extract_dow AS booking__ds__extract_dow - , subq_6.booking__ds__extract_doy AS booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day AS booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week AS booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month AS booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year AS booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day AS booking__paid_at__day - , subq_6.booking__paid_at__week AS booking__paid_at__week - , subq_6.booking__paid_at__month AS booking__paid_at__month - , subq_6.booking__paid_at__quarter AS booking__paid_at__quarter - , subq_6.booking__paid_at__year AS booking__paid_at__year - , subq_6.booking__paid_at__extract_year AS booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month AS booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.listing AS listing - , subq_6.guest AS guest - , subq_6.host AS host - , subq_6.booking__listing AS booking__listing - , subq_6.booking__guest AS booking__guest - , subq_6.booking__host AS booking__host - , subq_6.is_instant AS is_instant - , subq_6.booking__is_instant AS booking__is_instant - , subq_6.bookings AS bookings - , subq_6.instant_bookings AS instant_bookings - , subq_6.booking_value AS booking_value - , subq_6.max_booking_value AS max_booking_value - , subq_6.min_booking_value AS min_booking_value - , subq_6.bookers AS bookers - , subq_6.average_booking_value AS average_booking_value - , subq_6.referred_bookings AS referred_bookings - , subq_6.median_booking_value AS median_booking_value - , subq_6.booking_value_p99 AS booking_value_p99 - , subq_6.discrete_booking_value_p99 AS discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + EXTRACT(DAY_OF_WEEK FROM subq_16.metric_time__day) AS metric_time__extract_dow + , subq_15.ds__day AS ds__day + , subq_15.ds__week AS ds__week + , subq_15.ds__month AS ds__month + , subq_15.ds__quarter AS ds__quarter + , subq_15.ds__year AS ds__year + , subq_15.ds__extract_year AS ds__extract_year + , subq_15.ds__extract_quarter AS ds__extract_quarter + , subq_15.ds__extract_month AS ds__extract_month + , subq_15.ds__extract_day AS ds__extract_day + , subq_15.ds__extract_dow AS ds__extract_dow + , subq_15.ds__extract_doy AS ds__extract_doy + , subq_15.ds_partitioned__day AS ds_partitioned__day + , subq_15.ds_partitioned__week AS ds_partitioned__week + , subq_15.ds_partitioned__month AS ds_partitioned__month + , subq_15.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_15.ds_partitioned__year AS ds_partitioned__year + , subq_15.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_15.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_15.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_15.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_15.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_15.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_15.paid_at__day AS paid_at__day + , subq_15.paid_at__week AS paid_at__week + , subq_15.paid_at__month AS paid_at__month + , subq_15.paid_at__quarter AS paid_at__quarter + , subq_15.paid_at__year AS paid_at__year + , subq_15.paid_at__extract_year AS paid_at__extract_year + , subq_15.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_15.paid_at__extract_month AS paid_at__extract_month + , subq_15.paid_at__extract_day AS paid_at__extract_day + , subq_15.paid_at__extract_dow AS paid_at__extract_dow + , subq_15.paid_at__extract_doy AS paid_at__extract_doy + , subq_15.booking__ds__day AS booking__ds__day + , subq_15.booking__ds__week AS booking__ds__week + , subq_15.booking__ds__month AS booking__ds__month + , subq_15.booking__ds__quarter AS booking__ds__quarter + , subq_15.booking__ds__year AS booking__ds__year + , subq_15.booking__ds__extract_year AS booking__ds__extract_year + , subq_15.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_15.booking__ds__extract_month AS booking__ds__extract_month + , subq_15.booking__ds__extract_day AS booking__ds__extract_day + , subq_15.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_15.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_15.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_15.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_15.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_15.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_15.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_15.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_15.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_15.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_15.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_15.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_15.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_15.booking__paid_at__day AS booking__paid_at__day + , subq_15.booking__paid_at__week AS booking__paid_at__week + , subq_15.booking__paid_at__month AS booking__paid_at__month + , subq_15.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_15.booking__paid_at__year AS booking__paid_at__year + , subq_15.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_15.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_15.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_15.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_15.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_15.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_15.listing AS listing + , subq_15.guest AS guest + , subq_15.host AS host + , subq_15.booking__listing AS booking__listing + , subq_15.booking__guest AS booking__guest + , subq_15.booking__host AS booking__host + , subq_15.is_instant AS is_instant + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + , subq_15.instant_bookings AS instant_bookings + , subq_15.booking_value AS booking_value + , subq_15.max_booking_value AS max_booking_value + , subq_15.min_booking_value AS min_booking_value + , subq_15.bookers AS bookers + , subq_15.average_booking_value AS average_booking_value + , subq_15.referred_bookings AS referred_bookings + , subq_15.median_booking_value AS median_booking_value + , subq_15.booking_value_p99 AS booking_value_p99 + , subq_15.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_15.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_15.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - ) subq_7 + subq_17.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + ) subq_16 INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 + , 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_14 + ) subq_15 ON - DATE_ADD('day', -14, subq_7.metric_time__day) = subq_6.metric_time__day - ) subq_9 - ) subq_10 + DATE_ADD('day', -14, subq_16.metric_time__day) = subq_15.metric_time__day + ) subq_18 + ) subq_19 GROUP BY - subq_10.metric_time__extract_dow - ) subq_11 - ) subq_12 + subq_19.metric_time__extract_dow + ) subq_20 + ) subq_21 ON - subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow + subq_13.metric_time__extract_dow = subq_21.metric_time__extract_dow GROUP BY - COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) -) subq_13 + COALESCE(subq_13.metric_time__extract_dow, subq_21.metric_time__extract_dow) +) subq_22 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0_optimized.sql index 2ab3916ac3..6571d8444d 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) AS metric_time__extract_dow - , MAX(subq_18.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_27.metric_time__extract_dow, subq_35.metric_time__extract_dow) AS metric_time__extract_dow + , MAX(subq_27.bookings) AS bookings + , MAX(subq_35.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -21,35 +21,35 @@ FROM ( SELECT EXTRACT(DAY_OF_WEEK FROM ds) AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_16 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_25 GROUP BY metric_time__extract_dow - ) subq_18 + ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - EXTRACT(DAY_OF_WEEK FROM subq_22.ds) AS metric_time__extract_dow - , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + EXTRACT(DAY_OF_WEEK FROM subq_31.ds) AS metric_time__extract_dow + , SUM(subq_29.bookings) AS bookings_2_weeks_ago + FROM ***************************.mf_time_spine subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_20 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_29 ON - DATE_ADD('day', -14, subq_22.ds) = subq_20.metric_time__day + DATE_ADD('day', -14, subq_31.ds) = subq_29.metric_time__day GROUP BY - EXTRACT(DAY_OF_WEEK FROM subq_22.ds) - ) subq_26 + EXTRACT(DAY_OF_WEEK FROM subq_31.ds) + ) subq_35 ON - subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow + subq_27.metric_time__extract_dow = subq_35.metric_time__extract_dow GROUP BY - COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) -) subq_27 + COALESCE(subq_27.metric_time__extract_dow, subq_35.metric_time__extract_dow) +) subq_36 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_date_part__plan0.sql index e7549b14d6..8eec85d963 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_date_part__plan0.sql @@ -1,213 +1,213 @@ -- Compute Metrics via Expressions SELECT - subq_3.metric_time__extract_dow - , subq_3.bookings + subq_12.metric_time__extract_dow + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_dow - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_dow + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__extract_dow'] SELECT - subq_1.metric_time__extract_dow - , subq_1.bookings + subq_10.metric_time__extract_dow + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_dow -) subq_3 + subq_11.metric_time__extract_dow +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_date_part__plan0_optimized.sql index 3384f09601..761f51deeb 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_date_part__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT EXTRACT(DAY_OF_WEEK FROM ds) AS metric_time__extract_dow , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_dow diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_multiple_date_parts__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_multiple_date_parts__plan0.sql index 08567cdc3e..28ebe1e587 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_multiple_date_parts__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_multiple_date_parts__plan0.sql @@ -1,22 +1,22 @@ -- Compute Metrics via Expressions SELECT - 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.bookings + subq_12.metric_time__extract_year + , subq_12.metric_time__extract_quarter + , subq_12.metric_time__extract_month + , subq_12.metric_time__extract_day + , subq_12.metric_time__extract_dow + , subq_12.metric_time__extract_doy + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__extract_year - , subq_2.metric_time__extract_quarter - , subq_2.metric_time__extract_month - , subq_2.metric_time__extract_day - , subq_2.metric_time__extract_dow - , subq_2.metric_time__extract_doy - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: [ -- 'bookings', @@ -28,214 +28,214 @@ FROM ( -- 'metric_time__extract_year', -- ] SELECT - subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.bookings + subq_10.metric_time__extract_year + , subq_10.metric_time__extract_quarter + , subq_10.metric_time__extract_month + , subq_10.metric_time__extract_day + , subq_10.metric_time__extract_dow + , subq_10.metric_time__extract_doy + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__extract_year - , subq_2.metric_time__extract_quarter - , subq_2.metric_time__extract_month - , subq_2.metric_time__extract_day - , subq_2.metric_time__extract_dow - , subq_2.metric_time__extract_doy -) subq_3 + subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy +) subq_12 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_multiple_date_parts__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_multiple_date_parts__plan0_optimized.sql index 20e9a65c98..e6c8068a5a 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_multiple_date_parts__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_query_with_multiple_date_parts__plan0_optimized.sql @@ -28,8 +28,8 @@ FROM ( , EXTRACT(DAY_OF_WEEK FROM ds) AS metric_time__extract_dow , EXTRACT(doy FROM ds) AS metric_time__extract_doy , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_6 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_15 GROUP BY metric_time__extract_year , metric_time__extract_quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql index 6bb677070d..4ba8023fdb 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql @@ -91,91 +91,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql index c0d95fc9c1..e3b37eb1a3 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql @@ -87,4 +87,4 @@ SELECT , is_instant , is_instant AS booking__is_instant , booking_value AS booking_payments -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql index 5d05bdaaff..2701d256a9 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql @@ -103,91 +103,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql index 1c9d8067a9..9f74629f56 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql @@ -99,4 +99,4 @@ SELECT , booking_value AS discrete_booking_value_p99 , booking_value AS approximate_continuous_booking_value_p99 , booking_value AS approximate_discrete_booking_value_p99 -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0.sql index d358fe49a9..ccb553f344 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0.sql @@ -1,427 +1,427 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_payments) AS booking_payments + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_payments) AS booking_payments FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__day - ) subq_3 -) subq_4 + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_payments + subq_17.metric_time__day + , subq_17.booking_payments FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_payments) AS booking_payments + subq_16.metric_time__day + , SUM(subq_16.booking_payments) AS booking_payments FROM ( -- Pass Only Elements: ['booking_payments', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_payments + subq_15.metric_time__day + , subq_15.booking_payments FROM ( -- Metric Time Dimension 'paid_at' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.paid_at__day AS metric_time__day - , subq_5.paid_at__week AS metric_time__week - , subq_5.paid_at__month AS metric_time__month - , subq_5.paid_at__quarter AS metric_time__quarter - , subq_5.paid_at__year AS metric_time__year - , subq_5.paid_at__extract_year AS metric_time__extract_year - , subq_5.paid_at__extract_quarter AS metric_time__extract_quarter - , subq_5.paid_at__extract_month AS metric_time__extract_month - , subq_5.paid_at__extract_day AS metric_time__extract_day - , subq_5.paid_at__extract_dow AS metric_time__extract_dow - , subq_5.paid_at__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.booking_payments + 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.paid_at__day AS metric_time__day + , subq_14.paid_at__week AS metric_time__week + , subq_14.paid_at__month AS metric_time__month + , subq_14.paid_at__quarter AS metric_time__quarter + , subq_14.paid_at__year AS metric_time__year + , subq_14.paid_at__extract_year AS metric_time__extract_year + , subq_14.paid_at__extract_quarter AS metric_time__extract_quarter + , subq_14.paid_at__extract_month AS metric_time__extract_month + , subq_14.paid_at__extract_day AS metric_time__extract_day + , subq_14.paid_at__extract_dow AS metric_time__extract_dow + , subq_14.paid_at__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.booking_payments 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY metric_time__day - ) subq_8 -) subq_9 + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0_optimized.sql index 3a7ad735b4..d708d34109 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_payments) AS booking_payments + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_payments) AS booking_payments FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'paid_at' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC(paid_at, day) AS metric_time__day , SUM(booking_value) AS booking_payments - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY metric_time__day -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql index 80b3cbe42f..0388b56613 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql @@ -91,91 +91,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql index 4de651e561..1868c1588e 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql @@ -87,4 +87,4 @@ SELECT , is_instant , is_instant AS booking__is_instant , booking_value AS booking_payments -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql index d507cfa515..88d5d1906f 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql @@ -103,91 +103,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql index f4cf4bec00..c512d035ec 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql @@ -99,4 +99,4 @@ SELECT , booking_value AS discrete_booking_value_p99 , booking_value AS approximate_continuous_booking_value_p99 , booking_value AS approximate_discrete_booking_value_p99 -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0.sql index 206195d172..633aec9dba 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0.sql @@ -1,427 +1,427 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_payments) AS booking_payments + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_payments) AS booking_payments FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 -) subq_4 + subq_11.metric_time__day + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_payments + subq_17.metric_time__day + , subq_17.booking_payments FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_payments) AS booking_payments + subq_16.metric_time__day + , SUM(subq_16.booking_payments) AS booking_payments FROM ( -- Pass Only Elements: ['booking_payments', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_payments + subq_15.metric_time__day + , subq_15.booking_payments FROM ( -- Metric Time Dimension 'paid_at' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.paid_at__day AS metric_time__day - , subq_5.paid_at__week AS metric_time__week - , subq_5.paid_at__month AS metric_time__month - , subq_5.paid_at__quarter AS metric_time__quarter - , subq_5.paid_at__year AS metric_time__year - , subq_5.paid_at__extract_year AS metric_time__extract_year - , subq_5.paid_at__extract_quarter AS metric_time__extract_quarter - , subq_5.paid_at__extract_month AS metric_time__extract_month - , subq_5.paid_at__extract_day AS metric_time__extract_day - , subq_5.paid_at__extract_dow AS metric_time__extract_dow - , subq_5.paid_at__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.booking_payments + 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.paid_at__day AS metric_time__day + , subq_14.paid_at__week AS metric_time__week + , subq_14.paid_at__month AS metric_time__month + , subq_14.paid_at__quarter AS metric_time__quarter + , subq_14.paid_at__year AS metric_time__year + , subq_14.paid_at__extract_year AS metric_time__extract_year + , subq_14.paid_at__extract_quarter AS metric_time__extract_quarter + , subq_14.paid_at__extract_month AS metric_time__extract_month + , subq_14.paid_at__extract_day AS metric_time__extract_day + , subq_14.paid_at__extract_dow AS metric_time__extract_dow + , subq_14.paid_at__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.booking_payments 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_16.metric_time__day + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0_optimized.sql index 46a71e6b6f..a9e87c9254 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_payments) AS booking_payments + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_payments) AS booking_payments FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'paid_at' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC('day', paid_at) AS metric_time__day , SUM(booking_value) AS booking_payments - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', paid_at) -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql index 3388dce9c6..ff00293b12 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql @@ -91,91 +91,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql index 5421eb8d08..95cc2277b2 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql @@ -87,4 +87,4 @@ SELECT , is_instant , is_instant AS booking__is_instant , booking_value AS booking_payments -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql index d84dc7ddb7..9ac342b6b7 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql @@ -103,91 +103,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql index 4e5bf46c30..b64a17519b 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql @@ -99,4 +99,4 @@ SELECT , booking_value AS discrete_booking_value_p99 , booking_value AS approximate_continuous_booking_value_p99 , booking_value AS approximate_discrete_booking_value_p99 -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0.sql index 262a7abb6c..e3180fe3af 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0.sql @@ -1,427 +1,427 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_payments) AS booking_payments + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_payments) AS booking_payments FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 -) subq_4 + subq_11.metric_time__day + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_payments + subq_17.metric_time__day + , subq_17.booking_payments FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_payments) AS booking_payments + subq_16.metric_time__day + , SUM(subq_16.booking_payments) AS booking_payments FROM ( -- Pass Only Elements: ['booking_payments', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_payments + subq_15.metric_time__day + , subq_15.booking_payments FROM ( -- Metric Time Dimension 'paid_at' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.paid_at__day AS metric_time__day - , subq_5.paid_at__week AS metric_time__week - , subq_5.paid_at__month AS metric_time__month - , subq_5.paid_at__quarter AS metric_time__quarter - , subq_5.paid_at__year AS metric_time__year - , subq_5.paid_at__extract_year AS metric_time__extract_year - , subq_5.paid_at__extract_quarter AS metric_time__extract_quarter - , subq_5.paid_at__extract_month AS metric_time__extract_month - , subq_5.paid_at__extract_day AS metric_time__extract_day - , subq_5.paid_at__extract_dow AS metric_time__extract_dow - , subq_5.paid_at__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.booking_payments + 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.paid_at__day AS metric_time__day + , subq_14.paid_at__week AS metric_time__week + , subq_14.paid_at__month AS metric_time__month + , subq_14.paid_at__quarter AS metric_time__quarter + , subq_14.paid_at__year AS metric_time__year + , subq_14.paid_at__extract_year AS metric_time__extract_year + , subq_14.paid_at__extract_quarter AS metric_time__extract_quarter + , subq_14.paid_at__extract_month AS metric_time__extract_month + , subq_14.paid_at__extract_day AS metric_time__extract_day + , subq_14.paid_at__extract_dow AS metric_time__extract_dow + , subq_14.paid_at__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.booking_payments 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_16.metric_time__day + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0_optimized.sql index 46a71e6b6f..a9e87c9254 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_payments) AS booking_payments + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_payments) AS booking_payments FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'paid_at' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC('day', paid_at) AS metric_time__day , SUM(booking_value) AS booking_payments - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', paid_at) -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql index 3388dce9c6..ff00293b12 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql @@ -91,91 +91,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql index 5421eb8d08..95cc2277b2 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql @@ -87,4 +87,4 @@ SELECT , is_instant , is_instant AS booking__is_instant , booking_value AS booking_payments -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql index d84dc7ddb7..9ac342b6b7 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql @@ -103,91 +103,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql index 4e5bf46c30..b64a17519b 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql @@ -99,4 +99,4 @@ SELECT , booking_value AS discrete_booking_value_p99 , booking_value AS approximate_continuous_booking_value_p99 , booking_value AS approximate_discrete_booking_value_p99 -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0.sql index 262a7abb6c..e3180fe3af 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0.sql @@ -1,427 +1,427 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_payments) AS booking_payments + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_payments) AS booking_payments FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 -) subq_4 + subq_11.metric_time__day + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_payments + subq_17.metric_time__day + , subq_17.booking_payments FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_payments) AS booking_payments + subq_16.metric_time__day + , SUM(subq_16.booking_payments) AS booking_payments FROM ( -- Pass Only Elements: ['booking_payments', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_payments + subq_15.metric_time__day + , subq_15.booking_payments FROM ( -- Metric Time Dimension 'paid_at' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.paid_at__day AS metric_time__day - , subq_5.paid_at__week AS metric_time__week - , subq_5.paid_at__month AS metric_time__month - , subq_5.paid_at__quarter AS metric_time__quarter - , subq_5.paid_at__year AS metric_time__year - , subq_5.paid_at__extract_year AS metric_time__extract_year - , subq_5.paid_at__extract_quarter AS metric_time__extract_quarter - , subq_5.paid_at__extract_month AS metric_time__extract_month - , subq_5.paid_at__extract_day AS metric_time__extract_day - , subq_5.paid_at__extract_dow AS metric_time__extract_dow - , subq_5.paid_at__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.booking_payments + 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.paid_at__day AS metric_time__day + , subq_14.paid_at__week AS metric_time__week + , subq_14.paid_at__month AS metric_time__month + , subq_14.paid_at__quarter AS metric_time__quarter + , subq_14.paid_at__year AS metric_time__year + , subq_14.paid_at__extract_year AS metric_time__extract_year + , subq_14.paid_at__extract_quarter AS metric_time__extract_quarter + , subq_14.paid_at__extract_month AS metric_time__extract_month + , subq_14.paid_at__extract_day AS metric_time__extract_day + , subq_14.paid_at__extract_dow AS metric_time__extract_dow + , subq_14.paid_at__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.booking_payments 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_16.metric_time__day + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0_optimized.sql index 46a71e6b6f..a9e87c9254 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_payments) AS booking_payments + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_payments) AS booking_payments FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'paid_at' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC('day', paid_at) AS metric_time__day , SUM(booking_value) AS booking_payments - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', paid_at) -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql index c39e402440..675d367899 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql @@ -91,91 +91,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql index f8a48e796c..d92c8d8a6c 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql @@ -87,4 +87,4 @@ SELECT , is_instant , is_instant AS booking__is_instant , booking_value AS booking_payments -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql index e1280ee545..87bbb56140 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql @@ -103,91 +103,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql index 4279e7545e..0c2f267c46 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql @@ -99,4 +99,4 @@ SELECT , booking_value AS discrete_booking_value_p99 , booking_value AS approximate_continuous_booking_value_p99 , booking_value AS approximate_discrete_booking_value_p99 -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0.sql index 286fc71f31..b0679b1bc3 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0.sql @@ -1,427 +1,427 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_payments) AS booking_payments + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_payments) AS booking_payments FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 -) subq_4 + subq_11.metric_time__day + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_payments + subq_17.metric_time__day + , subq_17.booking_payments FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_payments) AS booking_payments + subq_16.metric_time__day + , SUM(subq_16.booking_payments) AS booking_payments FROM ( -- Pass Only Elements: ['booking_payments', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_payments + subq_15.metric_time__day + , subq_15.booking_payments FROM ( -- Metric Time Dimension 'paid_at' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.paid_at__day AS metric_time__day - , subq_5.paid_at__week AS metric_time__week - , subq_5.paid_at__month AS metric_time__month - , subq_5.paid_at__quarter AS metric_time__quarter - , subq_5.paid_at__year AS metric_time__year - , subq_5.paid_at__extract_year AS metric_time__extract_year - , subq_5.paid_at__extract_quarter AS metric_time__extract_quarter - , subq_5.paid_at__extract_month AS metric_time__extract_month - , subq_5.paid_at__extract_day AS metric_time__extract_day - , subq_5.paid_at__extract_dow AS metric_time__extract_dow - , subq_5.paid_at__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.booking_payments + 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.paid_at__day AS metric_time__day + , subq_14.paid_at__week AS metric_time__week + , subq_14.paid_at__month AS metric_time__month + , subq_14.paid_at__quarter AS metric_time__quarter + , subq_14.paid_at__year AS metric_time__year + , subq_14.paid_at__extract_year AS metric_time__extract_year + , subq_14.paid_at__extract_quarter AS metric_time__extract_quarter + , subq_14.paid_at__extract_month AS metric_time__extract_month + , subq_14.paid_at__extract_day AS metric_time__extract_day + , subq_14.paid_at__extract_dow AS metric_time__extract_dow + , subq_14.paid_at__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.booking_payments 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_16.metric_time__day + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0_optimized.sql index 46a71e6b6f..a9e87c9254 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_payments) AS booking_payments + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_payments) AS booking_payments FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'paid_at' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC('day', paid_at) AS metric_time__day , SUM(booking_value) AS booking_payments - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', paid_at) -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql index aa381107d7..ad30c2bcb8 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql @@ -91,91 +91,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql index e0b0390cac..d37a20ceb1 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql @@ -87,4 +87,4 @@ SELECT , is_instant , is_instant AS booking__is_instant , booking_value AS booking_payments -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql index 510806d5f8..e2f7af8a11 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql @@ -103,91 +103,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql index e44f38a400..7e5ad1d6f1 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql @@ -99,4 +99,4 @@ SELECT , booking_value AS discrete_booking_value_p99 , booking_value AS approximate_continuous_booking_value_p99 , booking_value AS approximate_discrete_booking_value_p99 -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0.sql index 7d5083d730..df4f97805c 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0.sql @@ -1,427 +1,427 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_payments) AS booking_payments + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_payments) AS booking_payments FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 -) subq_4 + subq_11.metric_time__day + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_payments + subq_17.metric_time__day + , subq_17.booking_payments FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_payments) AS booking_payments + subq_16.metric_time__day + , SUM(subq_16.booking_payments) AS booking_payments FROM ( -- Pass Only Elements: ['booking_payments', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_payments + subq_15.metric_time__day + , subq_15.booking_payments FROM ( -- Metric Time Dimension 'paid_at' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.paid_at__day AS metric_time__day - , subq_5.paid_at__week AS metric_time__week - , subq_5.paid_at__month AS metric_time__month - , subq_5.paid_at__quarter AS metric_time__quarter - , subq_5.paid_at__year AS metric_time__year - , subq_5.paid_at__extract_year AS metric_time__extract_year - , subq_5.paid_at__extract_quarter AS metric_time__extract_quarter - , subq_5.paid_at__extract_month AS metric_time__extract_month - , subq_5.paid_at__extract_day AS metric_time__extract_day - , subq_5.paid_at__extract_dow AS metric_time__extract_dow - , subq_5.paid_at__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.booking_payments + 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.paid_at__day AS metric_time__day + , subq_14.paid_at__week AS metric_time__week + , subq_14.paid_at__month AS metric_time__month + , subq_14.paid_at__quarter AS metric_time__quarter + , subq_14.paid_at__year AS metric_time__year + , subq_14.paid_at__extract_year AS metric_time__extract_year + , subq_14.paid_at__extract_quarter AS metric_time__extract_quarter + , subq_14.paid_at__extract_month AS metric_time__extract_month + , subq_14.paid_at__extract_day AS metric_time__extract_day + , subq_14.paid_at__extract_dow AS metric_time__extract_dow + , subq_14.paid_at__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.booking_payments 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_16.metric_time__day + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0_optimized.sql index 46a71e6b6f..a9e87c9254 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_payments) AS booking_payments + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_payments) AS booking_payments FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'paid_at' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC('day', paid_at) AS metric_time__day , SUM(booking_value) AS booking_payments - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', paid_at) -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql index 2d379ad8a9..52574048be 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql @@ -91,91 +91,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql index fe72c49a28..d4a0b62301 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql @@ -87,4 +87,4 @@ SELECT , is_instant , is_instant AS booking__is_instant , booking_value AS booking_payments -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql index 538f798748..f38530451e 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql @@ -103,91 +103,91 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql index 40a33f4f7c..883c1ac470 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql @@ -99,4 +99,4 @@ SELECT , booking_value AS discrete_booking_value_p99 , booking_value AS approximate_continuous_booking_value_p99 , booking_value AS approximate_discrete_booking_value_p99 -FROM ***************************.fct_bookings bookings_source_src_28001 +FROM ***************************.fct_bookings bookings_source_src_28000 diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_simple_query_with_metric_time_dimension__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_simple_query_with_metric_time_dimension__plan0.sql index e37d2870db..2c9802ead5 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_simple_query_with_metric_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_simple_query_with_metric_time_dimension__plan0.sql @@ -1,427 +1,427 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_payments) AS booking_payments + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_payments) AS booking_payments FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 -) subq_4 + subq_11.metric_time__day + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_payments + subq_17.metric_time__day + , subq_17.booking_payments FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_payments) AS booking_payments + subq_16.metric_time__day + , SUM(subq_16.booking_payments) AS booking_payments FROM ( -- Pass Only Elements: ['booking_payments', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_payments + subq_15.metric_time__day + , subq_15.booking_payments FROM ( -- Metric Time Dimension 'paid_at' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.paid_at__day AS metric_time__day - , subq_5.paid_at__week AS metric_time__week - , subq_5.paid_at__month AS metric_time__month - , subq_5.paid_at__quarter AS metric_time__quarter - , subq_5.paid_at__year AS metric_time__year - , subq_5.paid_at__extract_year AS metric_time__extract_year - , subq_5.paid_at__extract_quarter AS metric_time__extract_quarter - , subq_5.paid_at__extract_month AS metric_time__extract_month - , subq_5.paid_at__extract_day AS metric_time__extract_day - , subq_5.paid_at__extract_dow AS metric_time__extract_dow - , subq_5.paid_at__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.booking_payments + 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.paid_at__day AS metric_time__day + , subq_14.paid_at__week AS metric_time__week + , subq_14.paid_at__month AS metric_time__month + , subq_14.paid_at__quarter AS metric_time__quarter + , subq_14.paid_at__year AS metric_time__year + , subq_14.paid_at__extract_year AS metric_time__extract_year + , subq_14.paid_at__extract_quarter AS metric_time__extract_quarter + , subq_14.paid_at__extract_month AS metric_time__extract_month + , subq_14.paid_at__extract_day AS metric_time__extract_day + , subq_14.paid_at__extract_dow AS metric_time__extract_dow + , subq_14.paid_at__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.booking_payments 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_16.metric_time__day + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_simple_query_with_metric_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_simple_query_with_metric_time_dimension__plan0_optimized.sql index 46a71e6b6f..a9e87c9254 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_simple_query_with_metric_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Trino/test_simple_query_with_metric_time_dimension__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_payments) AS booking_payments + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_payments) AS booking_payments FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'paid_at' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC('day', paid_at) AS metric_time__day , SUM(booking_value) AS booking_payments - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', paid_at) -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml index 1d40ff0c74..00d8f5b406 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml @@ -21,7 +21,7 @@ - + diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_dimensions_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_dimensions_with_time_constraint__plan0.sql index 6401fd0627..92f2e17966 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_dimensions_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_dimensions_with_time_constraint__plan0.sql @@ -1,220 +1,220 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_10.metric_time__day + , subq_10.listing__is_lux_latest + , subq_10.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] 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.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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.metric_time__day + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Join Standard Outputs SELECT - 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 + 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_6.metric_time__day AS metric_time__day + , 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_8.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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_3 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_5.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,50 +230,50 @@ FROM ( , IF(EXTRACT(dayofweek FROM time_spine_src_0.ds) = 1, 7, EXTRACT(dayofweek FROM time_spine_src_0.ds) - 1) AS ds__extract_dow , EXTRACT(dayofyear FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_4 + ) subq_5 + ) subq_6 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_7.user + , subq_7.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_28009.ds, day) AS ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC(users_latest_src_28009.ds, day) AS user__ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS user__ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS user__ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS user__ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_7 + ) subq_8 ON - subq_0.user = subq_5.user - ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' -) subq_7 + subq_3.user = subq_8.user + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' +) subq_10 GROUP BY metric_time__day , listing__is_lux_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_dimensions_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_dimensions_with_time_constraint__plan0_optimized.sql index 5f0364638b..16316055de 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_dimensions_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_dimensions_with_time_constraint__plan0_optimized.sql @@ -3,15 +3,15 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC(time_spine_src_0.ds, day) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id WHERE DATE_TRUNC(time_spine_src_0.ds, day) BETWEEN '2020-01-01' AND '2020-01-03' GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_only__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_only__plan0.sql index 83fe7ceea3..fca6b1ab8c 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_only__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_only__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__day',] SELECT - subq_1.metric_time__day + subq_2.metric_time__day 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__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_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 @@ -41,7 +41,7 @@ FROM ( , IF(EXTRACT(dayofweek FROM time_spine_src_0.ds) = 1, 7, EXTRACT(dayofweek FROM time_spine_src_0.ds) - 1) AS ds__extract_dow , EXTRACT(dayofyear FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_quarter_alone__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_quarter_alone__plan0.sql index 12a0866e66..e4322c6873 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_quarter_alone__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_quarter_alone__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__quarter',] SELECT - subq_1.metric_time__quarter + subq_2.metric_time__quarter 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__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_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 @@ -41,7 +41,7 @@ FROM ( , IF(EXTRACT(dayofweek FROM time_spine_src_0.ds) = 1, 7, EXTRACT(dayofweek FROM time_spine_src_0.ds) - 1) AS ds__extract_dow , EXTRACT(dayofyear FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_with_other_dimensions__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_with_other_dimensions__plan0.sql index d93dc7e440..6346e2f538 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_with_other_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_with_other_dimensions__plan0.sql @@ -1,159 +1,159 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - 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 + subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.listing__ds__day AS listing__ds__day + , subq_1.listing__ds__week AS listing__ds__week + , subq_1.listing__ds__month AS listing__ds__month + , subq_1.listing__ds__quarter AS listing__ds__quarter + , subq_1.listing__ds__year AS listing__ds__year + , subq_1.listing__ds__extract_year AS listing__ds__extract_year + , subq_1.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_1.listing__ds__extract_month AS listing__ds__extract_month + , subq_1.listing__ds__extract_day AS listing__ds__extract_day + , subq_1.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_1.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_1.listing__created_at__day AS listing__created_at__day + , subq_1.listing__created_at__week AS listing__created_at__week + , subq_1.listing__created_at__month AS listing__created_at__month + , subq_1.listing__created_at__quarter AS listing__created_at__quarter + , subq_1.listing__created_at__year AS listing__created_at__year + , subq_1.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_1.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_1.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_1.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_1.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_1.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_4.metric_time__day AS metric_time__day + , subq_1.listing AS listing + , subq_1.user AS user + , subq_1.listing__user AS listing__user + , subq_1.country_latest AS country_latest + , subq_1.is_lux_latest AS is_lux_latest + , subq_1.capacity_latest AS capacity_latest + , subq_1.listing__country_latest AS listing__country_latest + , subq_1.listing__is_lux_latest AS listing__is_lux_latest + , subq_1.listing__capacity_latest AS listing__capacity_latest + , subq_6.home_state_latest AS user__home_state_latest + , subq_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_1 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_3.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + 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__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 FROM ( -- Time Spine SELECT @@ -169,48 +169,48 @@ FROM ( , IF(EXTRACT(dayofweek FROM time_spine_src_0.ds) = 1, 7, EXTRACT(dayofweek FROM time_spine_src_0.ds) - 1) AS ds__extract_dow , EXTRACT(dayofyear FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_2 + ) subq_3 + ) subq_4 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_5.user + , subq_5.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_28009.ds, day) AS ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC(users_latest_src_28009.ds, day) AS user__ds_latest__day - , DATE_TRUNC(users_latest_src_28009.ds, isoweek) AS user__ds_latest__week - , DATE_TRUNC(users_latest_src_28009.ds, month) AS user__ds_latest__month - , DATE_TRUNC(users_latest_src_28009.ds, quarter) AS user__ds_latest__quarter - , DATE_TRUNC(users_latest_src_28009.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28009.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28009.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_5 + ) subq_6 ON - subq_0.user = subq_5.user -) subq_6 + subq_1.user = subq_6.user +) subq_7 GROUP BY metric_time__day , listing__is_lux_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_with_other_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_with_other_dimensions__plan0_optimized.sql index d18a670826..5f3caa221e 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_with_other_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_metric_time_with_other_dimensions__plan0_optimized.sql @@ -2,15 +2,15 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC(time_spine_src_0.ds, day) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY metric_time__day , listing__is_lux_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_dimensions_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_dimensions_with_time_constraint__plan0.sql index 0f914702ac..fcbd857b94 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_dimensions_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_dimensions_with_time_constraint__plan0.sql @@ -1,220 +1,220 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_10.metric_time__day + , subq_10.listing__is_lux_latest + , subq_10.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] 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.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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.metric_time__day + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Join Standard Outputs SELECT - 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 + 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_6.metric_time__day AS metric_time__day + , 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_8.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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_3 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_5.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,51 +230,51 @@ FROM ( , EXTRACT(DAYOFWEEK_ISO FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_4 + ) subq_5 + ) subq_6 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_7.user + , subq_7.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_7 + ) subq_8 ON - subq_0.user = subq_5.user - ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' -) subq_7 + subq_3.user = subq_8.user + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' +) subq_10 GROUP BY - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_10.metric_time__day + , subq_10.listing__is_lux_latest + , subq_10.user__home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_dimensions_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_dimensions_with_time_constraint__plan0_optimized.sql index 978d323f8b..767b91883c 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_dimensions_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_dimensions_with_time_constraint__plan0_optimized.sql @@ -3,17 +3,17 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', time_spine_src_0.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id WHERE DATE_TRUNC('day', time_spine_src_0.ds) BETWEEN '2020-01-01' AND '2020-01-03' GROUP BY DATE_TRUNC('day', time_spine_src_0.ds) - , listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + , listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_only__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_only__plan0.sql index c1a209db11..cc17e67a3a 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_only__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_only__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__day',] SELECT - subq_1.metric_time__day + subq_2.metric_time__day 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__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_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 @@ -41,7 +41,7 @@ FROM ( , EXTRACT(DAYOFWEEK_ISO FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY - subq_1.metric_time__day + subq_2.metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_quarter_alone__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_quarter_alone__plan0.sql index 989ae2bffb..2d090ffbdb 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_quarter_alone__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_quarter_alone__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__quarter',] SELECT - subq_1.metric_time__quarter + subq_2.metric_time__quarter 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__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_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 @@ -41,7 +41,7 @@ FROM ( , EXTRACT(DAYOFWEEK_ISO FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY - subq_1.metric_time__quarter + subq_2.metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_with_other_dimensions__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_with_other_dimensions__plan0.sql index 9afc22ac0e..b395148a7b 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_with_other_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_with_other_dimensions__plan0.sql @@ -1,159 +1,159 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - 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 + subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.listing__ds__day AS listing__ds__day + , subq_1.listing__ds__week AS listing__ds__week + , subq_1.listing__ds__month AS listing__ds__month + , subq_1.listing__ds__quarter AS listing__ds__quarter + , subq_1.listing__ds__year AS listing__ds__year + , subq_1.listing__ds__extract_year AS listing__ds__extract_year + , subq_1.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_1.listing__ds__extract_month AS listing__ds__extract_month + , subq_1.listing__ds__extract_day AS listing__ds__extract_day + , subq_1.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_1.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_1.listing__created_at__day AS listing__created_at__day + , subq_1.listing__created_at__week AS listing__created_at__week + , subq_1.listing__created_at__month AS listing__created_at__month + , subq_1.listing__created_at__quarter AS listing__created_at__quarter + , subq_1.listing__created_at__year AS listing__created_at__year + , subq_1.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_1.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_1.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_1.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_1.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_1.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_4.metric_time__day AS metric_time__day + , subq_1.listing AS listing + , subq_1.user AS user + , subq_1.listing__user AS listing__user + , subq_1.country_latest AS country_latest + , subq_1.is_lux_latest AS is_lux_latest + , subq_1.capacity_latest AS capacity_latest + , subq_1.listing__country_latest AS listing__country_latest + , subq_1.listing__is_lux_latest AS listing__is_lux_latest + , subq_1.listing__capacity_latest AS listing__capacity_latest + , subq_6.home_state_latest AS user__home_state_latest + , subq_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_1 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_3.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + 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__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 FROM ( -- Time Spine SELECT @@ -169,49 +169,49 @@ FROM ( , EXTRACT(DAYOFWEEK_ISO FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_2 + ) subq_3 + ) subq_4 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_5.user + , subq_5.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_5 + ) subq_6 ON - subq_0.user = subq_5.user -) subq_6 + subq_1.user = subq_6.user +) subq_7 GROUP BY - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_with_other_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_with_other_dimensions__plan0_optimized.sql index 72d3126272..0bc006156d 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_with_other_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_metric_time_with_other_dimensions__plan0_optimized.sql @@ -2,16 +2,16 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', time_spine_src_0.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY DATE_TRUNC('day', time_spine_src_0.ds) - , listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + , listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_dimensions_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_dimensions_with_time_constraint__plan0.sql index c7ee79178d..63054d1979 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_dimensions_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_dimensions_with_time_constraint__plan0.sql @@ -1,220 +1,220 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_10.metric_time__day + , subq_10.listing__is_lux_latest + , subq_10.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] 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.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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.metric_time__day + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Join Standard Outputs SELECT - 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 + 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_6.metric_time__day AS metric_time__day + , 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_8.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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_3 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_5.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,51 +230,51 @@ FROM ( , EXTRACT(isodow FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_4 + ) subq_5 + ) subq_6 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_7.user + , subq_7.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_7 + ) subq_8 ON - subq_0.user = subq_5.user - ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' -) subq_7 + subq_3.user = subq_8.user + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' +) subq_10 GROUP BY - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_10.metric_time__day + , subq_10.listing__is_lux_latest + , subq_10.user__home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_dimensions_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_dimensions_with_time_constraint__plan0_optimized.sql index 978d323f8b..767b91883c 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_dimensions_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_dimensions_with_time_constraint__plan0_optimized.sql @@ -3,17 +3,17 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', time_spine_src_0.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id WHERE DATE_TRUNC('day', time_spine_src_0.ds) BETWEEN '2020-01-01' AND '2020-01-03' GROUP BY DATE_TRUNC('day', time_spine_src_0.ds) - , listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + , listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_only__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_only__plan0.sql index 99e55bdfbe..a6c97625fb 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_only__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_only__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__day',] SELECT - subq_1.metric_time__day + subq_2.metric_time__day 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__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_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 @@ -41,7 +41,7 @@ FROM ( , EXTRACT(isodow FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY - subq_1.metric_time__day + subq_2.metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_quarter_alone__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_quarter_alone__plan0.sql index 370ac1600e..f8c542ec64 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_quarter_alone__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_quarter_alone__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__quarter',] SELECT - subq_1.metric_time__quarter + subq_2.metric_time__quarter 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__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_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 @@ -41,7 +41,7 @@ FROM ( , EXTRACT(isodow FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY - subq_1.metric_time__quarter + subq_2.metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_with_other_dimensions__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_with_other_dimensions__plan0.sql index b74351891d..2f6d3d608f 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_with_other_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_with_other_dimensions__plan0.sql @@ -1,159 +1,159 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - 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 + subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.listing__ds__day AS listing__ds__day + , subq_1.listing__ds__week AS listing__ds__week + , subq_1.listing__ds__month AS listing__ds__month + , subq_1.listing__ds__quarter AS listing__ds__quarter + , subq_1.listing__ds__year AS listing__ds__year + , subq_1.listing__ds__extract_year AS listing__ds__extract_year + , subq_1.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_1.listing__ds__extract_month AS listing__ds__extract_month + , subq_1.listing__ds__extract_day AS listing__ds__extract_day + , subq_1.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_1.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_1.listing__created_at__day AS listing__created_at__day + , subq_1.listing__created_at__week AS listing__created_at__week + , subq_1.listing__created_at__month AS listing__created_at__month + , subq_1.listing__created_at__quarter AS listing__created_at__quarter + , subq_1.listing__created_at__year AS listing__created_at__year + , subq_1.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_1.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_1.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_1.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_1.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_1.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_4.metric_time__day AS metric_time__day + , subq_1.listing AS listing + , subq_1.user AS user + , subq_1.listing__user AS listing__user + , subq_1.country_latest AS country_latest + , subq_1.is_lux_latest AS is_lux_latest + , subq_1.capacity_latest AS capacity_latest + , subq_1.listing__country_latest AS listing__country_latest + , subq_1.listing__is_lux_latest AS listing__is_lux_latest + , subq_1.listing__capacity_latest AS listing__capacity_latest + , subq_6.home_state_latest AS user__home_state_latest + , subq_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_1 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_3.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + 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__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 FROM ( -- Time Spine SELECT @@ -169,49 +169,49 @@ FROM ( , EXTRACT(isodow FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_2 + ) subq_3 + ) subq_4 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_5.user + , subq_5.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_5 + ) subq_6 ON - subq_0.user = subq_5.user -) subq_6 + subq_1.user = subq_6.user +) subq_7 GROUP BY - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_with_other_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_with_other_dimensions__plan0_optimized.sql index 72d3126272..0bc006156d 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_with_other_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/DuckDB/test_metric_time_with_other_dimensions__plan0_optimized.sql @@ -2,16 +2,16 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', time_spine_src_0.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY DATE_TRUNC('day', time_spine_src_0.ds) - , listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + , listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_dimensions_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_dimensions_with_time_constraint__plan0.sql index c7ee79178d..63054d1979 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_dimensions_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_dimensions_with_time_constraint__plan0.sql @@ -1,220 +1,220 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_10.metric_time__day + , subq_10.listing__is_lux_latest + , subq_10.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] 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.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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.metric_time__day + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Join Standard Outputs SELECT - 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 + 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_6.metric_time__day AS metric_time__day + , 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_8.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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_3 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_5.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,51 +230,51 @@ FROM ( , EXTRACT(isodow FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_4 + ) subq_5 + ) subq_6 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_7.user + , subq_7.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_7 + ) subq_8 ON - subq_0.user = subq_5.user - ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' -) subq_7 + subq_3.user = subq_8.user + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' +) subq_10 GROUP BY - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_10.metric_time__day + , subq_10.listing__is_lux_latest + , subq_10.user__home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_dimensions_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_dimensions_with_time_constraint__plan0_optimized.sql index 978d323f8b..767b91883c 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_dimensions_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_dimensions_with_time_constraint__plan0_optimized.sql @@ -3,17 +3,17 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', time_spine_src_0.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id WHERE DATE_TRUNC('day', time_spine_src_0.ds) BETWEEN '2020-01-01' AND '2020-01-03' GROUP BY DATE_TRUNC('day', time_spine_src_0.ds) - , listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + , listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_only__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_only__plan0.sql index 99e55bdfbe..a6c97625fb 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_only__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_only__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__day',] SELECT - subq_1.metric_time__day + subq_2.metric_time__day 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__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_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 @@ -41,7 +41,7 @@ FROM ( , EXTRACT(isodow FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY - subq_1.metric_time__day + subq_2.metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_quarter_alone__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_quarter_alone__plan0.sql index 370ac1600e..f8c542ec64 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_quarter_alone__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_quarter_alone__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__quarter',] SELECT - subq_1.metric_time__quarter + subq_2.metric_time__quarter 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__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_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 @@ -41,7 +41,7 @@ FROM ( , EXTRACT(isodow FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY - subq_1.metric_time__quarter + subq_2.metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_with_other_dimensions__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_with_other_dimensions__plan0.sql index b74351891d..2f6d3d608f 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_with_other_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_with_other_dimensions__plan0.sql @@ -1,159 +1,159 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - 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 + subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.listing__ds__day AS listing__ds__day + , subq_1.listing__ds__week AS listing__ds__week + , subq_1.listing__ds__month AS listing__ds__month + , subq_1.listing__ds__quarter AS listing__ds__quarter + , subq_1.listing__ds__year AS listing__ds__year + , subq_1.listing__ds__extract_year AS listing__ds__extract_year + , subq_1.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_1.listing__ds__extract_month AS listing__ds__extract_month + , subq_1.listing__ds__extract_day AS listing__ds__extract_day + , subq_1.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_1.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_1.listing__created_at__day AS listing__created_at__day + , subq_1.listing__created_at__week AS listing__created_at__week + , subq_1.listing__created_at__month AS listing__created_at__month + , subq_1.listing__created_at__quarter AS listing__created_at__quarter + , subq_1.listing__created_at__year AS listing__created_at__year + , subq_1.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_1.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_1.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_1.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_1.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_1.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_4.metric_time__day AS metric_time__day + , subq_1.listing AS listing + , subq_1.user AS user + , subq_1.listing__user AS listing__user + , subq_1.country_latest AS country_latest + , subq_1.is_lux_latest AS is_lux_latest + , subq_1.capacity_latest AS capacity_latest + , subq_1.listing__country_latest AS listing__country_latest + , subq_1.listing__is_lux_latest AS listing__is_lux_latest + , subq_1.listing__capacity_latest AS listing__capacity_latest + , subq_6.home_state_latest AS user__home_state_latest + , subq_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_1 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_3.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + 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__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 FROM ( -- Time Spine SELECT @@ -169,49 +169,49 @@ FROM ( , EXTRACT(isodow FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_2 + ) subq_3 + ) subq_4 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_5.user + , subq_5.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_5 + ) subq_6 ON - subq_0.user = subq_5.user -) subq_6 + subq_1.user = subq_6.user +) subq_7 GROUP BY - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_with_other_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_with_other_dimensions__plan0_optimized.sql index 72d3126272..0bc006156d 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_with_other_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_metric_time_with_other_dimensions__plan0_optimized.sql @@ -2,16 +2,16 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', time_spine_src_0.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY DATE_TRUNC('day', time_spine_src_0.ds) - , listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + , listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_dimensions_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_dimensions_with_time_constraint__plan0.sql index b977753e00..b7fd257c96 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_dimensions_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_dimensions_with_time_constraint__plan0.sql @@ -1,220 +1,220 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_10.metric_time__day + , subq_10.listing__is_lux_latest + , subq_10.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] 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.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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.metric_time__day + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Join Standard Outputs SELECT - 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 + 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_6.metric_time__day AS metric_time__day + , 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_8.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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_3 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_5.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,51 +230,51 @@ FROM ( , CASE WHEN EXTRACT(dow FROM time_spine_src_0.ds) = 0 THEN EXTRACT(dow FROM time_spine_src_0.ds) + 7 ELSE EXTRACT(dow FROM time_spine_src_0.ds) END AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_4 + ) subq_5 + ) subq_6 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_7.user + , subq_7.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_7 + ) subq_8 ON - subq_0.user = subq_5.user - ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' -) subq_7 + subq_3.user = subq_8.user + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' +) subq_10 GROUP BY - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_10.metric_time__day + , subq_10.listing__is_lux_latest + , subq_10.user__home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_dimensions_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_dimensions_with_time_constraint__plan0_optimized.sql index 978d323f8b..767b91883c 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_dimensions_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_dimensions_with_time_constraint__plan0_optimized.sql @@ -3,17 +3,17 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', time_spine_src_0.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id WHERE DATE_TRUNC('day', time_spine_src_0.ds) BETWEEN '2020-01-01' AND '2020-01-03' GROUP BY DATE_TRUNC('day', time_spine_src_0.ds) - , listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + , listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_only__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_only__plan0.sql index 4b891850c0..8ba99684a9 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_only__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_only__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__day',] SELECT - subq_1.metric_time__day + subq_2.metric_time__day 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__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_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 @@ -41,7 +41,7 @@ FROM ( , CASE WHEN EXTRACT(dow FROM time_spine_src_0.ds) = 0 THEN EXTRACT(dow FROM time_spine_src_0.ds) + 7 ELSE EXTRACT(dow FROM time_spine_src_0.ds) END AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY - subq_1.metric_time__day + subq_2.metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_quarter_alone__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_quarter_alone__plan0.sql index 7baba3bce9..3ccf2dd2e9 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_quarter_alone__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_quarter_alone__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__quarter',] SELECT - subq_1.metric_time__quarter + subq_2.metric_time__quarter 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__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_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 @@ -41,7 +41,7 @@ FROM ( , CASE WHEN EXTRACT(dow FROM time_spine_src_0.ds) = 0 THEN EXTRACT(dow FROM time_spine_src_0.ds) + 7 ELSE EXTRACT(dow FROM time_spine_src_0.ds) END AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY - subq_1.metric_time__quarter + subq_2.metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_with_other_dimensions__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_with_other_dimensions__plan0.sql index a1707255e1..133b018e1b 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_with_other_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_with_other_dimensions__plan0.sql @@ -1,159 +1,159 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - 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 + subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.listing__ds__day AS listing__ds__day + , subq_1.listing__ds__week AS listing__ds__week + , subq_1.listing__ds__month AS listing__ds__month + , subq_1.listing__ds__quarter AS listing__ds__quarter + , subq_1.listing__ds__year AS listing__ds__year + , subq_1.listing__ds__extract_year AS listing__ds__extract_year + , subq_1.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_1.listing__ds__extract_month AS listing__ds__extract_month + , subq_1.listing__ds__extract_day AS listing__ds__extract_day + , subq_1.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_1.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_1.listing__created_at__day AS listing__created_at__day + , subq_1.listing__created_at__week AS listing__created_at__week + , subq_1.listing__created_at__month AS listing__created_at__month + , subq_1.listing__created_at__quarter AS listing__created_at__quarter + , subq_1.listing__created_at__year AS listing__created_at__year + , subq_1.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_1.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_1.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_1.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_1.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_1.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_4.metric_time__day AS metric_time__day + , subq_1.listing AS listing + , subq_1.user AS user + , subq_1.listing__user AS listing__user + , subq_1.country_latest AS country_latest + , subq_1.is_lux_latest AS is_lux_latest + , subq_1.capacity_latest AS capacity_latest + , subq_1.listing__country_latest AS listing__country_latest + , subq_1.listing__is_lux_latest AS listing__is_lux_latest + , subq_1.listing__capacity_latest AS listing__capacity_latest + , subq_6.home_state_latest AS user__home_state_latest + , subq_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_1 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_3.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + 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__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 FROM ( -- Time Spine SELECT @@ -169,49 +169,49 @@ FROM ( , CASE WHEN EXTRACT(dow FROM time_spine_src_0.ds) = 0 THEN EXTRACT(dow FROM time_spine_src_0.ds) + 7 ELSE EXTRACT(dow FROM time_spine_src_0.ds) END AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_2 + ) subq_3 + ) subq_4 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_5.user + , subq_5.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28009.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28009.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28009.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_5 + ) subq_6 ON - subq_0.user = subq_5.user -) subq_6 + subq_1.user = subq_6.user +) subq_7 GROUP BY - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_with_other_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_with_other_dimensions__plan0_optimized.sql index 72d3126272..0bc006156d 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_with_other_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_metric_time_with_other_dimensions__plan0_optimized.sql @@ -2,16 +2,16 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', time_spine_src_0.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY DATE_TRUNC('day', time_spine_src_0.ds) - , listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + , listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_dimensions_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_dimensions_with_time_constraint__plan0.sql index 8f74453b30..34f5cb2155 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_dimensions_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_dimensions_with_time_constraint__plan0.sql @@ -1,220 +1,220 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_10.metric_time__day + , subq_10.listing__is_lux_latest + , subq_10.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] 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.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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.metric_time__day + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Join Standard Outputs SELECT - 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 + 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_6.metric_time__day AS metric_time__day + , 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_8.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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_3 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_5.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,51 +230,51 @@ FROM ( , EXTRACT(dayofweekiso FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_4 + ) subq_5 + ) subq_6 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_7.user + , subq_7.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_7 + ) subq_8 ON - subq_0.user = subq_5.user - ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' -) subq_7 + subq_3.user = subq_8.user + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' +) subq_10 GROUP BY - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_10.metric_time__day + , subq_10.listing__is_lux_latest + , subq_10.user__home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_dimensions_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_dimensions_with_time_constraint__plan0_optimized.sql index 978d323f8b..767b91883c 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_dimensions_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_dimensions_with_time_constraint__plan0_optimized.sql @@ -3,17 +3,17 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', time_spine_src_0.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id WHERE DATE_TRUNC('day', time_spine_src_0.ds) BETWEEN '2020-01-01' AND '2020-01-03' GROUP BY DATE_TRUNC('day', time_spine_src_0.ds) - , listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + , listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_only__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_only__plan0.sql index 4cb966c506..dc3072243f 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_only__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_only__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__day',] SELECT - subq_1.metric_time__day + subq_2.metric_time__day 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__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_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 @@ -41,7 +41,7 @@ FROM ( , EXTRACT(dayofweekiso FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY - subq_1.metric_time__day + subq_2.metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_quarter_alone__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_quarter_alone__plan0.sql index 475700ea61..d33a765aa3 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_quarter_alone__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_quarter_alone__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__quarter',] SELECT - subq_1.metric_time__quarter + subq_2.metric_time__quarter 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__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_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 @@ -41,7 +41,7 @@ FROM ( , EXTRACT(dayofweekiso FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY - subq_1.metric_time__quarter + subq_2.metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_with_other_dimensions__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_with_other_dimensions__plan0.sql index 3147a5cdb7..c3c97f7d25 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_with_other_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_with_other_dimensions__plan0.sql @@ -1,159 +1,159 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - 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 + subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.listing__ds__day AS listing__ds__day + , subq_1.listing__ds__week AS listing__ds__week + , subq_1.listing__ds__month AS listing__ds__month + , subq_1.listing__ds__quarter AS listing__ds__quarter + , subq_1.listing__ds__year AS listing__ds__year + , subq_1.listing__ds__extract_year AS listing__ds__extract_year + , subq_1.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_1.listing__ds__extract_month AS listing__ds__extract_month + , subq_1.listing__ds__extract_day AS listing__ds__extract_day + , subq_1.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_1.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_1.listing__created_at__day AS listing__created_at__day + , subq_1.listing__created_at__week AS listing__created_at__week + , subq_1.listing__created_at__month AS listing__created_at__month + , subq_1.listing__created_at__quarter AS listing__created_at__quarter + , subq_1.listing__created_at__year AS listing__created_at__year + , subq_1.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_1.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_1.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_1.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_1.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_1.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_4.metric_time__day AS metric_time__day + , subq_1.listing AS listing + , subq_1.user AS user + , subq_1.listing__user AS listing__user + , subq_1.country_latest AS country_latest + , subq_1.is_lux_latest AS is_lux_latest + , subq_1.capacity_latest AS capacity_latest + , subq_1.listing__country_latest AS listing__country_latest + , subq_1.listing__is_lux_latest AS listing__is_lux_latest + , subq_1.listing__capacity_latest AS listing__capacity_latest + , subq_6.home_state_latest AS user__home_state_latest + , subq_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_1 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_3.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + 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__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 FROM ( -- Time Spine SELECT @@ -169,49 +169,49 @@ FROM ( , EXTRACT(dayofweekiso FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_2 + ) subq_3 + ) subq_4 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_5.user + , subq_5.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_5 + ) subq_6 ON - subq_0.user = subq_5.user -) subq_6 + subq_1.user = subq_6.user +) subq_7 GROUP BY - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_with_other_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_with_other_dimensions__plan0_optimized.sql index 72d3126272..0bc006156d 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_with_other_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_metric_time_with_other_dimensions__plan0_optimized.sql @@ -2,16 +2,16 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', time_spine_src_0.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY DATE_TRUNC('day', time_spine_src_0.ds) - , listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + , listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_dimensions_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_dimensions_with_time_constraint__plan0.sql index fa5cb77615..1a8f2bc452 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_dimensions_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_dimensions_with_time_constraint__plan0.sql @@ -1,220 +1,220 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_10.metric_time__day + , subq_10.listing__is_lux_latest + , subq_10.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] 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.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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.metric_time__day + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Join Standard Outputs SELECT - 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 + 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_6.metric_time__day AS metric_time__day + , 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_8.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 FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_3 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_5.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,51 +230,51 @@ FROM ( , EXTRACT(DAY_OF_WEEK FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_4 + ) subq_5 + ) subq_6 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_7.user + , subq_7.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_7 + ) subq_8 ON - 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 + subq_3.user = subq_8.user + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-03' +) subq_10 GROUP BY - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_10.metric_time__day + , subq_10.listing__is_lux_latest + , subq_10.user__home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_dimensions_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_dimensions_with_time_constraint__plan0_optimized.sql index 16efe80e80..8332f8602b 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_dimensions_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_dimensions_with_time_constraint__plan0_optimized.sql @@ -3,17 +3,17 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', time_spine_src_0.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id WHERE DATE_TRUNC('day', time_spine_src_0.ds) BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-03' GROUP BY DATE_TRUNC('day', time_spine_src_0.ds) - , listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + , listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_only__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_only__plan0.sql index b1c1cbc4d9..871fb961c6 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_only__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_only__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__day',] SELECT - subq_1.metric_time__day + subq_2.metric_time__day 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__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_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 @@ -41,7 +41,7 @@ FROM ( , EXTRACT(DAY_OF_WEEK FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY - subq_1.metric_time__day + subq_2.metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_quarter_alone__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_quarter_alone__plan0.sql index d81d111aab..7f7395b447 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_quarter_alone__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_quarter_alone__plan0.sql @@ -1,31 +1,31 @@ -- Pass Only Elements: ['metric_time__quarter',] SELECT - subq_1.metric_time__quarter + subq_2.metric_time__quarter 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__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_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 @@ -41,7 +41,7 @@ FROM ( , EXTRACT(DAY_OF_WEEK FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_0 -) subq_1 + ) subq_1 +) subq_2 GROUP BY - subq_1.metric_time__quarter + subq_2.metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_with_other_dimensions__plan0.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_with_other_dimensions__plan0.sql index 164e1880f1..47c006df92 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_with_other_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_with_other_dimensions__plan0.sql @@ -1,159 +1,159 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - 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 + subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.listing__ds__day AS listing__ds__day + , subq_1.listing__ds__week AS listing__ds__week + , subq_1.listing__ds__month AS listing__ds__month + , subq_1.listing__ds__quarter AS listing__ds__quarter + , subq_1.listing__ds__year AS listing__ds__year + , subq_1.listing__ds__extract_year AS listing__ds__extract_year + , subq_1.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_1.listing__ds__extract_month AS listing__ds__extract_month + , subq_1.listing__ds__extract_day AS listing__ds__extract_day + , subq_1.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_1.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_1.listing__created_at__day AS listing__created_at__day + , subq_1.listing__created_at__week AS listing__created_at__week + , subq_1.listing__created_at__month AS listing__created_at__month + , subq_1.listing__created_at__quarter AS listing__created_at__quarter + , subq_1.listing__created_at__year AS listing__created_at__year + , subq_1.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_1.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_1.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_1.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_1.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_1.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_4.metric_time__day AS metric_time__day + , subq_1.listing AS listing + , subq_1.user AS user + , subq_1.listing__user AS listing__user + , subq_1.country_latest AS country_latest + , subq_1.is_lux_latest AS is_lux_latest + , subq_1.capacity_latest AS capacity_latest + , subq_1.listing__country_latest AS listing__country_latest + , subq_1.listing__is_lux_latest AS listing__is_lux_latest + , subq_1.listing__capacity_latest AS listing__capacity_latest + , subq_6.home_state_latest AS user__home_state_latest + , subq_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 + , 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_1 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_2.metric_time__day + subq_3.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + 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__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 FROM ( -- Time Spine SELECT @@ -169,49 +169,49 @@ FROM ( , EXTRACT(DAY_OF_WEEK FROM time_spine_src_0.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_0.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_0 - ) subq_1 - ) subq_2 - ) subq_3 + ) subq_2 + ) subq_3 + ) subq_4 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_5.user + , subq_5.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_28009.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS ds_latest__extract_doy - , users_latest_src_28009.home_state_latest - , DATE_TRUNC('day', users_latest_src_28009.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28009.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28009.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28009.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28009.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28009.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28009.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28009.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28009.ds) AS user__ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28009.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28009.ds) AS user__ds_latest__extract_doy - , users_latest_src_28009.home_state_latest AS user__home_state_latest - , users_latest_src_28009.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28009 - ) 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_5 + ) subq_6 ON - subq_0.user = subq_5.user -) subq_6 + subq_1.user = subq_6.user +) subq_7 GROUP BY - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_with_other_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_with_other_dimensions__plan0_optimized.sql index 72d3126272..0bc006156d 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_with_other_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_metric_time_with_other_dimensions__plan0_optimized.sql @@ -2,16 +2,16 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT DATE_TRUNC('day', time_spine_src_0.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , users_latest_src_28009.home_state_latest AS user__home_state_latest -FROM ***************************.dim_listings_latest listings_latest_src_28005 + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest +FROM ***************************.dim_listings_latest listings_latest_src_28000 CROSS JOIN ***************************.mf_time_spine time_spine_src_0 FULL OUTER JOIN - ***************************.dim_users_latest users_latest_src_28009 + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28005.user_id = users_latest_src_28009.user_id + listings_latest_src_28000.user_id = users_latest_src_28000.user_id GROUP BY DATE_TRUNC('day', time_spine_src_0.ds) - , listings_latest_src_28005.is_lux - , users_latest_src_28009.home_state_latest + , listings_latest_src_28000.is_lux + , users_latest_src_28000.home_state_latest diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_dimensions_with_time_constraint__plan0.xml b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_dimensions_with_time_constraint__plan0.xml index ad143eb1a6..23c077bc4c 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_dimensions_with_time_constraint__plan0.xml +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_dimensions_with_time_constraint__plan0.xml @@ -433,13 +433,13 @@ - + - + diff --git a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_with_other_dimensions__plan0.xml b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_with_other_dimensions__plan0.xml index cfc768f43c..e1ade2306a 100644 --- a/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_with_other_dimensions__plan0.xml +++ b/metricflow/test/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_with_other_dimensions__plan0.xml @@ -212,13 +212,13 @@ - + - + diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0.sql index 8c92f3919c..0f1544680d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0.sql @@ -1,439 +1,439 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_value) AS booking_value + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__day - ) subq_3 -) subq_4 + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_value) AS booking_value + subq_16.metric_time__day + , SUM(subq_16.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_value + subq_15.metric_time__day + , subq_15.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY metric_time__day - ) subq_8 -) subq_9 + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0_optimized.sql index 3fa4fb3aa6..87c0b2709d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY metric_time__day -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql index 56d1966a90..64eedb3232 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql @@ -68,62 +68,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0_optimized.sql index 22b719da85..1653ada5bd 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_3 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql index b99d711af8..d379c07e68 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -1,383 +1,383 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_19.booking__is_instant + , subq_19.bookings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_18.booking__is_instant + , SUM(subq_18.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_17.booking__is_instant + , subq_17.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_16.booking__is_instant + , subq_16.listing__country_latest + , subq_16.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.booking__is_instant + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.listing + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__country_latest = 'us' - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY booking__is_instant -) subq_10 +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index fdbb61ce0e..433c9799b5 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.country AS listing__country_latest - , subq_13.bookings AS bookings + subq_22.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.country AS listing__country_latest + , subq_22.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -20,13 +20,13 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28005.listing_id -) subq_18 + subq_22.listing = listings_latest_src_28000.listing_id +) subq_27 WHERE listing__country_latest = 'us' GROUP BY booking__is_instant diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql index 4c230ae33f..9ee4b88ab1 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql @@ -1,139 +1,139 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS family_bookings + subq_11.metric_time__day + , subq_11.bookings AS family_bookings FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_10.metric_time__day + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.listing__capacity - , subq_6.bookings + subq_8.metric_time__day + , subq_8.listing__capacity + , subq_8.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.listing__capacity - , subq_5.bookings + subq_7.metric_time__day + , subq_7.listing__capacity + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_4.window_start__day AS listing__window_start__day - , subq_4.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_4.capacity AS listing__capacity - , subq_2.bookings AS bookings + subq_4.metric_time__day AS metric_time__day + , subq_6.window_start__day AS listing__window_start__day + , subq_6.window_end__day AS listing__window_end__day + , subq_4.listing AS listing + , subq_6.capacity AS listing__capacity + , subq_4.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_3.metric_time__day + , subq_3.listing + , subq_3.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + 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.user + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.booking__user + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.bookers + , subq_2.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -220,94 +220,94 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_2 + ) subq_3 + ) subq_4 LEFT OUTER JOIN ( -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_3.window_start__day - , subq_3.window_end__day - , subq_3.listing - , subq_3.capacity + subq_5.window_start__day + , subq_5.window_end__day + , subq_5.listing + , subq_5.capacity FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC(listings_src_26002.active_from, isoweek) AS window_start__week - , DATE_TRUNC(listings_src_26002.active_from, month) AS window_start__month - , DATE_TRUNC(listings_src_26002.active_from, quarter) AS window_start__quarter - , DATE_TRUNC(listings_src_26002.active_from, year) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_26002.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_26002.active_from) - 1) AS window_start__extract_dow - , EXTRACT(dayofyear FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC(listings_src_26002.active_to, isoweek) AS window_end__week - , DATE_TRUNC(listings_src_26002.active_to, month) AS window_end__month - , DATE_TRUNC(listings_src_26002.active_to, quarter) AS window_end__quarter - , DATE_TRUNC(listings_src_26002.active_to, year) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_26002.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_26002.active_to) - 1) AS window_end__extract_dow - , EXTRACT(dayofyear FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC(listings_src_26002.active_from, isoweek) AS listing__window_start__week - , DATE_TRUNC(listings_src_26002.active_from, month) AS listing__window_start__month - , DATE_TRUNC(listings_src_26002.active_from, quarter) AS listing__window_start__quarter - , DATE_TRUNC(listings_src_26002.active_from, year) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_26002.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_26002.active_from) - 1) AS listing__window_start__extract_dow - , EXTRACT(dayofyear FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC(listings_src_26002.active_to, isoweek) AS listing__window_end__week - , DATE_TRUNC(listings_src_26002.active_to, month) AS listing__window_end__month - , DATE_TRUNC(listings_src_26002.active_to, quarter) AS listing__window_end__quarter - , DATE_TRUNC(listings_src_26002.active_to, year) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_26002.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_26002.active_to) - 1) AS listing__window_end__extract_dow - , EXTRACT(dayofyear FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 - ) subq_4 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC(listings_src_26000.active_from, isoweek) AS window_start__week + , DATE_TRUNC(listings_src_26000.active_from, month) AS window_start__month + , DATE_TRUNC(listings_src_26000.active_from, quarter) AS window_start__quarter + , DATE_TRUNC(listings_src_26000.active_from, year) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_26000.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_26000.active_from) - 1) AS window_start__extract_dow + , EXTRACT(dayofyear FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC(listings_src_26000.active_to, isoweek) AS window_end__week + , DATE_TRUNC(listings_src_26000.active_to, month) AS window_end__month + , DATE_TRUNC(listings_src_26000.active_to, quarter) AS window_end__quarter + , DATE_TRUNC(listings_src_26000.active_to, year) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_26000.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_26000.active_to) - 1) AS window_end__extract_dow + , EXTRACT(dayofyear FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC(listings_src_26000.active_from, isoweek) AS listing__window_start__week + , DATE_TRUNC(listings_src_26000.active_from, month) AS listing__window_start__month + , DATE_TRUNC(listings_src_26000.active_from, quarter) AS listing__window_start__quarter + , DATE_TRUNC(listings_src_26000.active_from, year) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_26000.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_26000.active_from) - 1) AS listing__window_start__extract_dow + , EXTRACT(dayofyear FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC(listings_src_26000.active_to, isoweek) AS listing__window_end__week + , DATE_TRUNC(listings_src_26000.active_to, month) AS listing__window_end__month + , DATE_TRUNC(listings_src_26000.active_to, quarter) AS listing__window_end__quarter + , DATE_TRUNC(listings_src_26000.active_to, year) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_26000.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_26000.active_to) - 1) AS listing__window_end__extract_dow + , EXTRACT(dayofyear FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_4.listing + subq_4.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_4.window_start__day + subq_4.metric_time__day >= subq_6.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_4.window_end__day + subq_4.metric_time__day < subq_6.window_end__day ) OR ( - subq_4.window_end__day IS NULL + subq_6.window_end__day IS NULL ) ) ) - ) subq_5 - ) subq_6 + ) subq_7 + ) subq_8 WHERE listing__capacity > 2 - ) subq_7 - ) subq_8 + ) subq_9 + ) subq_10 GROUP BY metric_time__day -) subq_9 +) subq_11 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql index ce73eff7d1..d78cf5a237 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_12.metric_time__day AS metric_time__day - , listings_src_26002.capacity AS listing__capacity - , subq_12.bookings AS bookings + subq_14.metric_time__day AS metric_time__day + , listings_src_26000.capacity AS listing__capacity + , subq_14.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -21,24 +21,24 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_12 + ) subq_14 LEFT OUTER JOIN - ***************************.dim_listings listings_src_26002 + ***************************.dim_listings listings_src_26000 ON ( - subq_12.listing = listings_src_26002.listing_id + subq_14.listing = listings_src_26000.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_26002.active_from + subq_14.metric_time__day >= listings_src_26000.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_26002.active_to + subq_14.metric_time__day < listings_src_26000.active_to ) OR ( - listings_src_26002.active_to IS NULL + listings_src_26000.active_to IS NULL ) ) ) -) subq_16 +) subq_18 WHERE listing__capacity > 2 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0.sql index f4431e9d9f..37fd6cbf20 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0.sql @@ -1,220 +1,220 @@ -- Order By [] Limit 1 SELECT - subq_4.ds__day - , subq_4.bookings + subq_13.ds__day + , subq_13.bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.bookings + subq_12.ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.bookings + subq_10.ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY ds__day - ) subq_3 -) subq_4 + ) subq_12 +) subq_13 LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0_optimized.sql index 939d96354f..de05ca3ce1 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0_optimized.sql @@ -11,8 +11,8 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_7 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_16 GROUP BY ds__day LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0.sql index b3c6c96ff2..973323b7bc 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0.sql @@ -1,150 +1,150 @@ -- Compute Metrics via Expressions SELECT - subq_3.listing__country_latest - , subq_3.listings + subq_12.listing__country_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_2.listing__country_latest - , SUM(subq_2.listings) AS listings + subq_11.listing__country_latest + , SUM(subq_11.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'listing__country_latest'] SELECT - subq_1.listing__country_latest - , subq_1.listings + subq_10.listing__country_latest + , subq_10.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.created_at__day - , subq_0.created_at__week - , subq_0.created_at__month - , subq_0.created_at__quarter - , subq_0.created_at__year - , subq_0.created_at__extract_year - , subq_0.created_at__extract_quarter - , subq_0.created_at__extract_month - , subq_0.created_at__extract_day - , subq_0.created_at__extract_dow - , subq_0.created_at__extract_doy - , subq_0.listing__ds__day - , subq_0.listing__ds__week - , subq_0.listing__ds__month - , subq_0.listing__ds__quarter - , subq_0.listing__ds__year - , subq_0.listing__ds__extract_year - , subq_0.listing__ds__extract_quarter - , subq_0.listing__ds__extract_month - , subq_0.listing__ds__extract_day - , subq_0.listing__ds__extract_dow - , subq_0.listing__ds__extract_doy - , subq_0.listing__created_at__day - , subq_0.listing__created_at__week - , subq_0.listing__created_at__month - , subq_0.listing__created_at__quarter - , subq_0.listing__created_at__year - , subq_0.listing__created_at__extract_year - , subq_0.listing__created_at__extract_quarter - , subq_0.listing__created_at__extract_month - , subq_0.listing__created_at__extract_day - , subq_0.listing__created_at__extract_dow - , subq_0.listing__created_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.user - , subq_0.listing__user - , subq_0.country_latest - , subq_0.is_lux_latest - , subq_0.capacity_latest - , subq_0.listing__country_latest - , subq_0.listing__is_lux_latest - , subq_0.listing__capacity_latest - , subq_0.listings - , subq_0.largest_listing - , subq_0.smallest_listing + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY listing__country_latest -) subq_3 +) subq_12 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0_optimized.sql index 8486e86449..c0733d39a6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT country AS listing__country_latest , 1 AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_6 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_15 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql index 3f622f3979..b4d0d039fd 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql @@ -1,1003 +1,1003 @@ -- Compute Metrics via Expressions SELECT - subq_29.metric_time__day + subq_38.metric_time__day , average_booking_value * bookings / NULLIF(booking_value, 0) AS lux_booking_value_rate_expr FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_28.booking_value) AS booking_value + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_37.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_19.metric_time__day + , subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , AVG(subq_9.average_booking_value) AS average_booking_value + subq_18.metric_time__day + , AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_17.metric_time__day + , subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.metric_time__day + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.metric_time__day + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.average_booking_value AS average_booking_value + subq_11.metric_time__day AS metric_time__day + , subq_11.listing AS listing + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.average_booking_value + subq_10.metric_time__day + , subq_10.listing + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY metric_time__day - ) subq_10 - ) subq_11 + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day - , subq_22.bookings + subq_31.metric_time__day + , subq_31.bookings FROM ( -- Aggregate Measures SELECT - subq_21.metric_time__day - , SUM(subq_21.bookings) AS bookings + subq_30.metric_time__day + , SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.metric_time__day + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.metric_time__day + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.metric_time__day AS metric_time__day + , subq_23.listing AS listing + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.bookings + subq_22.metric_time__day + , subq_22.listing + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE listing__is_lux_latest - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 GROUP BY metric_time__day - ) subq_22 - ) subq_23 + ) subq_31 + ) subq_32 ON - subq_11.metric_time__day = subq_23.metric_time__day + subq_20.metric_time__day = subq_32.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.booking_value + subq_36.metric_time__day + , subq_36.booking_value FROM ( -- Aggregate Measures SELECT - subq_26.metric_time__day - , SUM(subq_26.booking_value) AS booking_value + subq_35.metric_time__day + , SUM(subq_35.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_25.metric_time__day - , subq_25.booking_value + subq_34.metric_time__day + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 GROUP BY metric_time__day - ) subq_27 - ) subq_28 + ) subq_36 + ) subq_37 ON - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day) = subq_37.metric_time__day GROUP BY metric_time__day -) subq_29 +) subq_38 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql index afb361b267..f9e3cbfc56 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) AS metric_time__day - , MAX(subq_41.average_booking_value) AS average_booking_value - , MAX(subq_53.bookings) AS bookings - , MAX(subq_58.booking_value) AS booking_value + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day, subq_67.metric_time__day) AS metric_time__day + , MAX(subq_50.average_booking_value) AS average_booking_value + , MAX(subq_62.bookings) AS bookings + , MAX(subq_67.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -21,19 +21,19 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - DATE_TRUNC(bookings_source_src_28001.ds, day) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + DATE_TRUNC(bookings_source_src_28000.ds, day) AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_37 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_46 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_41 + ) subq_50 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -46,9 +46,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_44.metric_time__day AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_44.bookings AS bookings + subq_53.metric_time__day AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_53.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -57,19 +57,19 @@ FROM ( DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_44 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_53 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_44.listing = listings_latest_src_28005.listing_id - ) subq_49 + subq_53.listing = listings_latest_src_28000.listing_id + ) subq_58 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_53 + ) subq_62 ON - subq_41.metric_time__day = subq_53.metric_time__day + subq_50.metric_time__day = subq_62.metric_time__day FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -79,12 +79,12 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY metric_time__day - ) subq_58 + ) subq_67 ON - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day) = subq_58.metric_time__day + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day) = subq_67.metric_time__day GROUP BY metric_time__day -) subq_59 +) subq_68 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql index 2ef25fcc8b..3558188a1f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,460 +1,460 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , CAST(subq_12.booking_value_with_is_instant_constraint AS FLOAT64) / CAST(NULLIF(subq_12.booking_value, 0) AS FLOAT64) AS instant_booking_value_ratio + subq_21.metric_time__day + , CAST(subq_21.booking_value_with_is_instant_constraint AS FLOAT64) / CAST(NULLIF(subq_21.booking_value, 0) AS FLOAT64) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , MAX(subq_6.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_11.booking_value) AS booking_value + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day + , MAX(subq_15.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_20.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.booking_value AS booking_value_with_is_instant_constraint + subq_14.metric_time__day + , subq_14.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.booking_value) AS booking_value + subq_13.metric_time__day + , SUM(subq_13.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.booking_value + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY metric_time__day - ) subq_5 - ) subq_6 + ) subq_14 + ) subq_15 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_19.metric_time__day + , subq_19.booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.booking_value) AS booking_value + subq_18.metric_time__day + , SUM(subq_18.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.ds_partitioned__day + , subq_16.ds_partitioned__week + , subq_16.ds_partitioned__month + , subq_16.ds_partitioned__quarter + , subq_16.ds_partitioned__year + , subq_16.ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy + , subq_16.paid_at__day + , subq_16.paid_at__week + , subq_16.paid_at__month + , subq_16.paid_at__quarter + , subq_16.paid_at__year + , subq_16.paid_at__extract_year + , subq_16.paid_at__extract_quarter + , subq_16.paid_at__extract_month + , subq_16.paid_at__extract_day + , subq_16.paid_at__extract_dow + , subq_16.paid_at__extract_doy + , subq_16.booking__ds__day + , subq_16.booking__ds__week + , subq_16.booking__ds__month + , subq_16.booking__ds__quarter + , subq_16.booking__ds__year + , subq_16.booking__ds__extract_year + , subq_16.booking__ds__extract_quarter + , subq_16.booking__ds__extract_month + , subq_16.booking__ds__extract_day + , subq_16.booking__ds__extract_dow + , subq_16.booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day + , subq_16.booking__paid_at__week + , subq_16.booking__paid_at__month + , subq_16.booking__paid_at__quarter + , subq_16.booking__paid_at__year + , subq_16.booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.listing + , subq_16.guest + , subq_16.host + , subq_16.booking__listing + , subq_16.booking__guest + , subq_16.booking__host + , subq_16.is_instant + , subq_16.booking__is_instant + , subq_16.bookings + , subq_16.instant_bookings + , subq_16.booking_value + , subq_16.max_booking_value + , subq_16.min_booking_value + , subq_16.bookers + , subq_16.average_booking_value + , subq_16.referred_bookings + , subq_16.median_booking_value + , subq_16.booking_value_p99 + , subq_16.discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 + , subq_16.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_7 - ) subq_8 - ) subq_9 + , 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_16 + ) subq_17 + ) subq_18 GROUP BY metric_time__day - ) subq_10 - ) subq_11 + ) subq_19 + ) subq_20 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_15.metric_time__day = subq_20.metric_time__day GROUP BY metric_time__day -) subq_12 +) subq_21 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql index 1b73aecc3e..8c5317ed46 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/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_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , MAX(subq_19.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_24.booking_value) AS booking_value + COALESCE(subq_28.metric_time__day, subq_33.metric_time__day) AS metric_time__day + , MAX(subq_28.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_33.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC(ds, day) AS metric_time__day , is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_28 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -39,12 +39,12 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY metric_time__day - ) subq_24 + ) subq_33 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_28.metric_time__day = subq_33.metric_time__day GROUP BY metric_time__day -) subq_25 +) subq_34 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 26ea88f8a2..154399d604 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,234 +1,234 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day + subq_15.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.bookings AS delayed_bookings + subq_14.metric_time__day + , subq_14.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_13.metric_time__day + , SUM(subq_13.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE NOT booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY metric_time__day - ) subq_5 -) subq_6 + ) subq_14 +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 315465981a..6ddee5faad 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -18,9 +18,9 @@ FROM ( DATE_TRUNC(ds, day) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 3e678aca18..f6c0a27948 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -1,366 +1,366 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_10.bookings AS FLOAT64) / CAST(NULLIF(subq_10.listings, 0) AS FLOAT64) AS bookings_per_listing + CAST(subq_19.bookings AS FLOAT64) / CAST(NULLIF(subq_19.listings, 0) AS FLOAT64) AS bookings_per_listing FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_4.bookings) AS bookings - , MAX(subq_9.listings) AS listings + MAX(subq_13.bookings) AS bookings + , MAX(subq_18.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.bookings + subq_12.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_2.bookings) AS bookings + SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_1.bookings + subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 - ) subq_4 + , 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_9 + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.listings + subq_17.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_7.listings) AS listings + SUM(subq_16.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_6.listings + subq_15.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.created_at__day - , subq_5.created_at__week - , subq_5.created_at__month - , subq_5.created_at__quarter - , subq_5.created_at__year - , subq_5.created_at__extract_year - , subq_5.created_at__extract_quarter - , subq_5.created_at__extract_month - , subq_5.created_at__extract_day - , subq_5.created_at__extract_dow - , subq_5.created_at__extract_doy - , subq_5.listing__ds__day - , subq_5.listing__ds__week - , subq_5.listing__ds__month - , subq_5.listing__ds__quarter - , subq_5.listing__ds__year - , subq_5.listing__ds__extract_year - , subq_5.listing__ds__extract_quarter - , subq_5.listing__ds__extract_month - , subq_5.listing__ds__extract_day - , subq_5.listing__ds__extract_dow - , subq_5.listing__ds__extract_doy - , subq_5.listing__created_at__day - , subq_5.listing__created_at__week - , subq_5.listing__created_at__month - , subq_5.listing__created_at__quarter - , subq_5.listing__created_at__year - , subq_5.listing__created_at__extract_year - , subq_5.listing__created_at__extract_quarter - , subq_5.listing__created_at__extract_month - , subq_5.listing__created_at__extract_day - , subq_5.listing__created_at__extract_dow - , subq_5.listing__created_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.user - , subq_5.listing__user - , subq_5.country_latest - , subq_5.is_lux_latest - , subq_5.capacity_latest - , subq_5.listing__country_latest - , subq_5.listing__is_lux_latest - , subq_5.listing__capacity_latest - , subq_5.listings - , subq_5.largest_listing - , subq_5.smallest_listing + 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.created_at__day + , subq_14.created_at__week + , subq_14.created_at__month + , subq_14.created_at__quarter + , subq_14.created_at__year + , subq_14.created_at__extract_year + , subq_14.created_at__extract_quarter + , subq_14.created_at__extract_month + , subq_14.created_at__extract_day + , subq_14.created_at__extract_dow + , subq_14.created_at__extract_doy + , subq_14.listing__ds__day + , subq_14.listing__ds__week + , subq_14.listing__ds__month + , subq_14.listing__ds__quarter + , subq_14.listing__ds__year + , subq_14.listing__ds__extract_year + , subq_14.listing__ds__extract_quarter + , subq_14.listing__ds__extract_month + , subq_14.listing__ds__extract_day + , subq_14.listing__ds__extract_dow + , subq_14.listing__ds__extract_doy + , subq_14.listing__created_at__day + , subq_14.listing__created_at__week + , subq_14.listing__created_at__month + , subq_14.listing__created_at__quarter + , subq_14.listing__created_at__year + , subq_14.listing__created_at__extract_year + , subq_14.listing__created_at__extract_quarter + , subq_14.listing__created_at__extract_month + , subq_14.listing__created_at__extract_day + , subq_14.listing__created_at__extract_dow + , subq_14.listing__created_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.user + , subq_14.listing__user + , subq_14.country_latest + , subq_14.is_lux_latest + , subq_14.capacity_latest + , subq_14.listing__country_latest + , subq_14.listing__is_lux_latest + , subq_14.listing__capacity_latest + , subq_14.listings + , subq_14.largest_listing + , subq_14.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_5 - ) subq_6 - ) subq_7 - ) subq_8 - ) subq_9 -) subq_10 + , 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_14 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index e711c1aa00..51883eb703 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_15.bookings) AS FLOAT64) / CAST(NULLIF(MAX(subq_20.listings), 0) AS FLOAT64) AS bookings_per_listing + CAST(MAX(subq_24.bookings) AS FLOAT64) / CAST(NULLIF(MAX(subq_29.listings), 0) AS FLOAT64) AS bookings_per_listing FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -10,8 +10,8 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_24 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -20,5 +20,5 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_20 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_29 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_categorical__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_categorical__plan0.sql index d626d79921..0435a81912 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_categorical__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_categorical__plan0.sql @@ -10,62 +10,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_categorical__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_categorical__plan0_optimized.sql index 4f2c89fad9..d150e133e9 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_categorical__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_categorical__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 GROUP BY listing__country_latest ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time__plan0.sql index e807808c9b..bc8a2057e4 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY booking__paid_at__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time__plan0_optimized.sql index 248c95268a..06b4483f39 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__day',] SELECT DATE_TRUNC(paid_at, day) AS booking__paid_at__day - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY booking__paid_at__day ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time_quarter__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time_quarter__plan0.sql index cf955fce66..b7db3c2043 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time_quarter__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time_quarter__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time_quarter__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time_quarter__plan0_optimized.sql index 86016c5223..b2feebb321 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time_quarter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_min_max_only_time_quarter__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__quarter',] SELECT DATE_TRUNC(paid_at, quarter) AS booking__paid_at__quarter - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY booking__paid_at__quarter ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql index 0c04d7784a..23c5e7aa85 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__user__home_state_latest - , subq_10.bookings + subq_23.metric_time__day + , subq_23.listing__user__home_state_latest + , subq_23.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest - , SUM(subq_9.bookings) AS bookings + subq_22.metric_time__day + , subq_22.listing__user__home_state_latest + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__home_state_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__user__home_state_latest - , subq_8.bookings + subq_21.metric_time__day + , subq_21.listing__user__home_state_latest + , subq_21.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.window_start__day AS listing__window_start__day - , subq_7.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_7.user__home_state_latest AS listing__user__home_state_latest - , subq_2.bookings AS bookings + subq_15.metric_time__day AS metric_time__day + , subq_20.window_start__day AS listing__window_start__day + , subq_20.window_end__day AS listing__window_end__day + , subq_15.listing AS listing + , subq_20.user__home_state_latest AS listing__user__home_state_latest + , subq_15.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_14.metric_time__day + , subq_14.listing + , subq_14.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.user + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.booking__user + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.bookers + , subq_13.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,142 +211,142 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_13 + ) subq_14 + ) subq_15 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_6.window_start__day - , subq_6.window_end__day - , subq_6.listing - , subq_6.user__home_state_latest + subq_19.window_start__day + , subq_19.window_end__day + , subq_19.listing + , subq_19.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_3.window_start__day AS window_start__day - , subq_3.window_start__week AS window_start__week - , subq_3.window_start__month AS window_start__month - , subq_3.window_start__quarter AS window_start__quarter - , subq_3.window_start__year AS window_start__year - , subq_3.window_start__extract_year AS window_start__extract_year - , subq_3.window_start__extract_quarter AS window_start__extract_quarter - , subq_3.window_start__extract_month AS window_start__extract_month - , subq_3.window_start__extract_day AS window_start__extract_day - , subq_3.window_start__extract_dow AS window_start__extract_dow - , subq_3.window_start__extract_doy AS window_start__extract_doy - , subq_3.window_end__day AS window_end__day - , subq_3.window_end__week AS window_end__week - , subq_3.window_end__month AS window_end__month - , subq_3.window_end__quarter AS window_end__quarter - , subq_3.window_end__year AS window_end__year - , subq_3.window_end__extract_year AS window_end__extract_year - , subq_3.window_end__extract_quarter AS window_end__extract_quarter - , subq_3.window_end__extract_month AS window_end__extract_month - , subq_3.window_end__extract_day AS window_end__extract_day - , subq_3.window_end__extract_dow AS window_end__extract_dow - , subq_3.window_end__extract_doy AS window_end__extract_doy - , subq_3.listing__window_start__day AS listing__window_start__day - , subq_3.listing__window_start__week AS listing__window_start__week - , subq_3.listing__window_start__month AS listing__window_start__month - , subq_3.listing__window_start__quarter AS listing__window_start__quarter - , subq_3.listing__window_start__year AS listing__window_start__year - , subq_3.listing__window_start__extract_year AS listing__window_start__extract_year - , subq_3.listing__window_start__extract_quarter AS listing__window_start__extract_quarter - , subq_3.listing__window_start__extract_month AS listing__window_start__extract_month - , subq_3.listing__window_start__extract_day AS listing__window_start__extract_day - , subq_3.listing__window_start__extract_dow AS listing__window_start__extract_dow - , subq_3.listing__window_start__extract_doy AS listing__window_start__extract_doy - , subq_3.listing__window_end__day AS listing__window_end__day - , subq_3.listing__window_end__week AS listing__window_end__week - , subq_3.listing__window_end__month AS listing__window_end__month - , subq_3.listing__window_end__quarter AS listing__window_end__quarter - , subq_3.listing__window_end__year AS listing__window_end__year - , subq_3.listing__window_end__extract_year AS listing__window_end__extract_year - , subq_3.listing__window_end__extract_quarter AS listing__window_end__extract_quarter - , subq_3.listing__window_end__extract_month AS listing__window_end__extract_month - , subq_3.listing__window_end__extract_day AS listing__window_end__extract_day - , subq_3.listing__window_end__extract_dow AS listing__window_end__extract_dow - , subq_3.listing__window_end__extract_doy AS listing__window_end__extract_doy - , subq_5.ds__day AS user__ds__day - , subq_5.ds__week AS user__ds__week - , subq_5.ds__month AS user__ds__month - , subq_5.ds__quarter AS user__ds__quarter - , subq_5.ds__year AS user__ds__year - , subq_5.ds__extract_year AS user__ds__extract_year - , subq_5.ds__extract_quarter AS user__ds__extract_quarter - , subq_5.ds__extract_month AS user__ds__extract_month - , subq_5.ds__extract_day AS user__ds__extract_day - , subq_5.ds__extract_dow AS user__ds__extract_dow - , subq_5.ds__extract_doy AS user__ds__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country AS country - , subq_3.is_lux AS is_lux - , subq_3.capacity AS capacity - , subq_3.listing__country AS listing__country - , subq_3.listing__is_lux AS listing__is_lux - , subq_3.listing__capacity AS listing__capacity - , subq_5.home_state_latest AS user__home_state_latest + subq_16.window_start__day AS window_start__day + , subq_16.window_start__week AS window_start__week + , subq_16.window_start__month AS window_start__month + , subq_16.window_start__quarter AS window_start__quarter + , subq_16.window_start__year AS window_start__year + , subq_16.window_start__extract_year AS window_start__extract_year + , subq_16.window_start__extract_quarter AS window_start__extract_quarter + , subq_16.window_start__extract_month AS window_start__extract_month + , subq_16.window_start__extract_day AS window_start__extract_day + , subq_16.window_start__extract_dow AS window_start__extract_dow + , subq_16.window_start__extract_doy AS window_start__extract_doy + , subq_16.window_end__day AS window_end__day + , subq_16.window_end__week AS window_end__week + , subq_16.window_end__month AS window_end__month + , subq_16.window_end__quarter AS window_end__quarter + , subq_16.window_end__year AS window_end__year + , subq_16.window_end__extract_year AS window_end__extract_year + , subq_16.window_end__extract_quarter AS window_end__extract_quarter + , subq_16.window_end__extract_month AS window_end__extract_month + , subq_16.window_end__extract_day AS window_end__extract_day + , subq_16.window_end__extract_dow AS window_end__extract_dow + , subq_16.window_end__extract_doy AS window_end__extract_doy + , subq_16.listing__window_start__day AS listing__window_start__day + , subq_16.listing__window_start__week AS listing__window_start__week + , subq_16.listing__window_start__month AS listing__window_start__month + , subq_16.listing__window_start__quarter AS listing__window_start__quarter + , subq_16.listing__window_start__year AS listing__window_start__year + , subq_16.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_16.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_16.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_16.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_16.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_16.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_16.listing__window_end__day AS listing__window_end__day + , subq_16.listing__window_end__week AS listing__window_end__week + , subq_16.listing__window_end__month AS listing__window_end__month + , subq_16.listing__window_end__quarter AS listing__window_end__quarter + , subq_16.listing__window_end__year AS listing__window_end__year + , subq_16.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_16.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_16.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_16.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_16.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_16.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_18.ds__day AS user__ds__day + , subq_18.ds__week AS user__ds__week + , subq_18.ds__month AS user__ds__month + , subq_18.ds__quarter AS user__ds__quarter + , subq_18.ds__year AS user__ds__year + , subq_18.ds__extract_year AS user__ds__extract_year + , subq_18.ds__extract_quarter AS user__ds__extract_quarter + , subq_18.ds__extract_month AS user__ds__extract_month + , subq_18.ds__extract_day AS user__ds__extract_day + , subq_18.ds__extract_dow AS user__ds__extract_dow + , subq_18.ds__extract_doy AS user__ds__extract_doy + , subq_16.listing AS listing + , subq_16.user AS user + , subq_16.listing__user AS listing__user + , subq_16.country AS country + , subq_16.is_lux AS is_lux + , subq_16.capacity AS capacity + , subq_16.listing__country AS listing__country + , subq_16.listing__is_lux AS listing__is_lux + , subq_16.listing__capacity AS listing__capacity + , subq_18.home_state_latest AS user__home_state_latest FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC(listings_src_26002.active_from, isoweek) AS window_start__week - , DATE_TRUNC(listings_src_26002.active_from, month) AS window_start__month - , DATE_TRUNC(listings_src_26002.active_from, quarter) AS window_start__quarter - , DATE_TRUNC(listings_src_26002.active_from, year) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_26002.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_26002.active_from) - 1) AS window_start__extract_dow - , EXTRACT(dayofyear FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC(listings_src_26002.active_to, isoweek) AS window_end__week - , DATE_TRUNC(listings_src_26002.active_to, month) AS window_end__month - , DATE_TRUNC(listings_src_26002.active_to, quarter) AS window_end__quarter - , DATE_TRUNC(listings_src_26002.active_to, year) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_26002.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_26002.active_to) - 1) AS window_end__extract_dow - , EXTRACT(dayofyear FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC(listings_src_26002.active_from, isoweek) AS listing__window_start__week - , DATE_TRUNC(listings_src_26002.active_from, month) AS listing__window_start__month - , DATE_TRUNC(listings_src_26002.active_from, quarter) AS listing__window_start__quarter - , DATE_TRUNC(listings_src_26002.active_from, year) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_26002.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_26002.active_from) - 1) AS listing__window_start__extract_dow - , EXTRACT(dayofyear FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC(listings_src_26002.active_to, isoweek) AS listing__window_end__week - , DATE_TRUNC(listings_src_26002.active_to, month) AS listing__window_end__month - , DATE_TRUNC(listings_src_26002.active_to, quarter) AS listing__window_end__quarter - , DATE_TRUNC(listings_src_26002.active_to, year) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , IF(EXTRACT(dayofweek FROM listings_src_26002.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_26002.active_to) - 1) AS listing__window_end__extract_dow - , EXTRACT(dayofyear FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC(listings_src_26000.active_from, isoweek) AS window_start__week + , DATE_TRUNC(listings_src_26000.active_from, month) AS window_start__month + , DATE_TRUNC(listings_src_26000.active_from, quarter) AS window_start__quarter + , DATE_TRUNC(listings_src_26000.active_from, year) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_26000.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_26000.active_from) - 1) AS window_start__extract_dow + , EXTRACT(dayofyear FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC(listings_src_26000.active_to, isoweek) AS window_end__week + , DATE_TRUNC(listings_src_26000.active_to, month) AS window_end__month + , DATE_TRUNC(listings_src_26000.active_to, quarter) AS window_end__quarter + , DATE_TRUNC(listings_src_26000.active_to, year) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_26000.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_26000.active_to) - 1) AS window_end__extract_dow + , EXTRACT(dayofyear FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC(listings_src_26000.active_from, isoweek) AS listing__window_start__week + , DATE_TRUNC(listings_src_26000.active_from, month) AS listing__window_start__month + , DATE_TRUNC(listings_src_26000.active_from, quarter) AS listing__window_start__quarter + , DATE_TRUNC(listings_src_26000.active_from, year) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_26000.active_from) = 1, 7, EXTRACT(dayofweek FROM listings_src_26000.active_from) - 1) AS listing__window_start__extract_dow + , EXTRACT(dayofyear FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC(listings_src_26000.active_to, isoweek) AS listing__window_end__week + , DATE_TRUNC(listings_src_26000.active_to, month) AS listing__window_end__month + , DATE_TRUNC(listings_src_26000.active_to, quarter) AS listing__window_end__quarter + , DATE_TRUNC(listings_src_26000.active_to, year) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , IF(EXTRACT(dayofweek FROM listings_src_26000.active_to) = 1, 7, EXTRACT(dayofweek FROM listings_src_26000.active_to) - 1) AS listing__window_end__extract_dow + , EXTRACT(dayofyear FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_16 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,83 +376,83 @@ FROM ( -- 'user', -- ] SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.user__ds__day - , subq_4.user__ds__week - , subq_4.user__ds__month - , subq_4.user__ds__quarter - , subq_4.user__ds__year - , subq_4.user__ds__extract_year - , subq_4.user__ds__extract_quarter - , subq_4.user__ds__extract_month - , subq_4.user__ds__extract_day - , subq_4.user__ds__extract_dow - , subq_4.user__ds__extract_doy - , subq_4.user - , subq_4.home_state_latest - , subq_4.user__home_state_latest + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.user__ds__day + , subq_17.user__ds__week + , subq_17.user__ds__month + , subq_17.user__ds__quarter + , subq_17.user__ds__year + , subq_17.user__ds__extract_year + , subq_17.user__ds__extract_quarter + , subq_17.user__ds__extract_month + , subq_17.user__ds__extract_day + , subq_17.user__ds__extract_dow + , subq_17.user__ds__extract_doy + , subq_17.user + , subq_17.home_state_latest + , subq_17.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC(users_latest_src_26006.ds, day) AS ds__day - , DATE_TRUNC(users_latest_src_26006.ds, isoweek) AS ds__week - , DATE_TRUNC(users_latest_src_26006.ds, month) AS ds__month - , DATE_TRUNC(users_latest_src_26006.ds, quarter) AS ds__quarter - , DATE_TRUNC(users_latest_src_26006.ds, year) AS ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_26006.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_26006.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_26006.ds) AS ds__extract_doy - , users_latest_src_26006.home_state_latest - , DATE_TRUNC(users_latest_src_26006.ds, day) AS user__ds__day - , DATE_TRUNC(users_latest_src_26006.ds, isoweek) AS user__ds__week - , DATE_TRUNC(users_latest_src_26006.ds, month) AS user__ds__month - , DATE_TRUNC(users_latest_src_26006.ds, quarter) AS user__ds__quarter - , DATE_TRUNC(users_latest_src_26006.ds, year) AS user__ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS user__ds__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_26006.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_26006.ds) - 1) AS user__ds__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_26006.ds) AS user__ds__extract_doy - , users_latest_src_26006.home_state_latest AS user__home_state_latest - , users_latest_src_26006.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_26006 - ) subq_4 - ) subq_5 + DATE_TRUNC(users_latest_src_26000.ds, day) AS ds__day + , DATE_TRUNC(users_latest_src_26000.ds, isoweek) AS ds__week + , DATE_TRUNC(users_latest_src_26000.ds, month) AS ds__month + , DATE_TRUNC(users_latest_src_26000.ds, quarter) AS ds__quarter + , DATE_TRUNC(users_latest_src_26000.ds, year) AS ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_26000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_26000.ds) AS ds__extract_doy + , users_latest_src_26000.home_state_latest + , DATE_TRUNC(users_latest_src_26000.ds, day) AS user__ds__day + , DATE_TRUNC(users_latest_src_26000.ds, isoweek) AS user__ds__week + , DATE_TRUNC(users_latest_src_26000.ds, month) AS user__ds__month + , DATE_TRUNC(users_latest_src_26000.ds, quarter) AS user__ds__quarter + , DATE_TRUNC(users_latest_src_26000.ds, year) AS user__ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS user__ds__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_26000.ds) - 1) AS user__ds__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_26000.ds) AS user__ds__extract_doy + , users_latest_src_26000.home_state_latest AS user__home_state_latest + , users_latest_src_26000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_26000 + ) subq_17 + ) subq_18 ON - subq_3.user = subq_5.user - ) subq_6 - ) subq_7 + subq_16.user = subq_18.user + ) subq_19 + ) subq_20 ON ( - subq_2.listing = subq_7.listing + subq_15.listing = subq_20.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.window_start__day + subq_15.metric_time__day >= subq_20.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.window_end__day + subq_15.metric_time__day < subq_20.window_end__day ) OR ( - subq_7.window_end__day IS NULL + subq_20.window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_21 + ) subq_22 GROUP BY metric_time__day , listing__user__home_state_latest -) subq_10 +) subq_23 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 6a2a62a0a4..9100c823f6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.user__home_state_latest AS listing__user__home_state_latest - , SUM(subq_13.bookings) AS bookings + subq_26.metric_time__day AS metric_time__day + , subq_31.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_26.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,32 +15,32 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_26 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - listings_src_26002.active_from AS window_start__day - , listings_src_26002.active_to AS window_end__day - , listings_src_26002.listing_id AS listing - , users_latest_src_26006.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings listings_src_26002 + listings_src_26000.active_from AS window_start__day + , listings_src_26000.active_to AS window_end__day + , listings_src_26000.listing_id AS listing + , users_latest_src_26000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings listings_src_26000 LEFT OUTER JOIN - ***************************.dim_users_latest users_latest_src_26006 + ***************************.dim_users_latest users_latest_src_26000 ON - listings_src_26002.user_id = users_latest_src_26006.user_id -) subq_18 + listings_src_26000.user_id = users_latest_src_26000.user_id +) subq_31 ON ( - subq_13.listing = subq_18.listing + subq_26.listing = subq_31.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_26.metric_time__day >= subq_31.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_26.metric_time__day < subq_31.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_31.window_end__day IS NULL ) ) ) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql index 9577af0b81..b52f8e4ab1 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__lux_listing__is_confirmed_lux - , subq_10.bookings + subq_15.metric_time__day + , subq_15.listing__lux_listing__is_confirmed_lux + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux - , SUM(subq_9.bookings) AS bookings + subq_14.metric_time__day + , subq_14.listing__lux_listing__is_confirmed_lux + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__lux_listing__is_confirmed_lux', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__lux_listing__is_confirmed_lux - , subq_8.bookings + subq_13.metric_time__day + , subq_13.listing__lux_listing__is_confirmed_lux + , subq_13.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.lux_listing__window_start__day AS listing__lux_listing__window_start__day - , subq_7.lux_listing__window_end__day AS listing__lux_listing__window_end__day - , subq_2.listing AS listing - , subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , subq_2.bookings AS bookings + subq_7.metric_time__day AS metric_time__day + , subq_12.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_12.lux_listing__window_end__day AS listing__lux_listing__window_end__day + , subq_7.listing AS listing + , subq_12.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_7.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_6.metric_time__day + , subq_6.listing + , subq_6.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.ds__day AS metric_time__day + , subq_5.ds__week AS metric_time__week + , subq_5.ds__month AS metric_time__month + , subq_5.ds__quarter AS metric_time__quarter + , subq_5.ds__year AS metric_time__year + , subq_5.ds__extract_year AS metric_time__extract_year + , subq_5.ds__extract_quarter AS metric_time__extract_quarter + , subq_5.ds__extract_month AS metric_time__extract_month + , subq_5.ds__extract_day AS metric_time__extract_day + , subq_5.ds__extract_dow AS metric_time__extract_dow + , subq_5.ds__extract_doy AS metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.user + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.booking__user + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.bookings + , subq_5.instant_bookings + , subq_5.booking_value + , subq_5.bookers + , subq_5.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,53 +211,53 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_5 + ) subq_6 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - subq_6.lux_listing__window_start__day - , subq_6.lux_listing__window_end__day - , subq_6.listing - , subq_6.lux_listing__is_confirmed_lux + subq_11.lux_listing__window_start__day + , subq_11.lux_listing__window_end__day + , subq_11.listing + , subq_11.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_5.window_start__day AS lux_listing__window_start__day - , subq_5.window_start__week AS lux_listing__window_start__week - , subq_5.window_start__month AS lux_listing__window_start__month - , subq_5.window_start__quarter AS lux_listing__window_start__quarter - , subq_5.window_start__year AS lux_listing__window_start__year - , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_5.window_end__day AS lux_listing__window_end__day - , subq_5.window_end__week AS lux_listing__window_end__week - , subq_5.window_end__month AS lux_listing__window_end__month - , subq_5.window_end__quarter AS lux_listing__window_end__quarter - , subq_5.window_end__year AS lux_listing__window_end__year - , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_3.listing AS listing - , subq_3.lux_listing AS lux_listing - , subq_3.listing__lux_listing AS listing__lux_listing - , subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux + subq_10.window_start__day AS lux_listing__window_start__day + , subq_10.window_start__week AS lux_listing__window_start__week + , subq_10.window_start__month AS lux_listing__window_start__month + , subq_10.window_start__quarter AS lux_listing__window_start__quarter + , subq_10.window_start__year AS lux_listing__window_start__year + , subq_10.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_10.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_10.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_10.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_10.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_10.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_10.window_end__day AS lux_listing__window_end__day + , subq_10.window_end__week AS lux_listing__window_end__week + , subq_10.window_end__month AS lux_listing__window_end__month + , subq_10.window_end__quarter AS lux_listing__window_end__quarter + , subq_10.window_end__year AS lux_listing__window_end__year + , subq_10.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_10.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_10.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_10.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_10.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_10.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_8.listing AS listing + , subq_8.lux_listing AS lux_listing + , subq_8.listing__lux_listing AS listing__lux_listing + , subq_10.is_confirmed_lux AS lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT - lux_listing_mapping_src_26003.listing_id AS listing - , lux_listing_mapping_src_26003.lux_listing_id AS lux_listing - , lux_listing_mapping_src_26003.lux_listing_id AS listing__lux_listing - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 - ) subq_3 + lux_listing_mapping_src_26000.listing_id AS listing + , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing + , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 + ) subq_8 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,127 +309,127 @@ FROM ( -- 'lux_listing', -- ] SELECT - subq_4.window_start__day - , subq_4.window_start__week - , subq_4.window_start__month - , subq_4.window_start__quarter - , subq_4.window_start__year - , subq_4.window_start__extract_year - , subq_4.window_start__extract_quarter - , subq_4.window_start__extract_month - , subq_4.window_start__extract_day - , subq_4.window_start__extract_dow - , subq_4.window_start__extract_doy - , subq_4.window_end__day - , subq_4.window_end__week - , subq_4.window_end__month - , subq_4.window_end__quarter - , subq_4.window_end__year - , subq_4.window_end__extract_year - , subq_4.window_end__extract_quarter - , subq_4.window_end__extract_month - , subq_4.window_end__extract_day - , subq_4.window_end__extract_dow - , subq_4.window_end__extract_doy - , subq_4.lux_listing__window_start__day - , subq_4.lux_listing__window_start__week - , subq_4.lux_listing__window_start__month - , subq_4.lux_listing__window_start__quarter - , subq_4.lux_listing__window_start__year - , subq_4.lux_listing__window_start__extract_year - , subq_4.lux_listing__window_start__extract_quarter - , subq_4.lux_listing__window_start__extract_month - , subq_4.lux_listing__window_start__extract_day - , subq_4.lux_listing__window_start__extract_dow - , subq_4.lux_listing__window_start__extract_doy - , subq_4.lux_listing__window_end__day - , subq_4.lux_listing__window_end__week - , subq_4.lux_listing__window_end__month - , subq_4.lux_listing__window_end__quarter - , subq_4.lux_listing__window_end__year - , subq_4.lux_listing__window_end__extract_year - , subq_4.lux_listing__window_end__extract_quarter - , subq_4.lux_listing__window_end__extract_month - , subq_4.lux_listing__window_end__extract_day - , subq_4.lux_listing__window_end__extract_dow - , subq_4.lux_listing__window_end__extract_doy - , subq_4.lux_listing - , subq_4.is_confirmed_lux - , subq_4.lux_listing__is_confirmed_lux + subq_9.window_start__day + , subq_9.window_start__week + , subq_9.window_start__month + , subq_9.window_start__quarter + , subq_9.window_start__year + , subq_9.window_start__extract_year + , subq_9.window_start__extract_quarter + , subq_9.window_start__extract_month + , subq_9.window_start__extract_day + , subq_9.window_start__extract_dow + , subq_9.window_start__extract_doy + , subq_9.window_end__day + , subq_9.window_end__week + , subq_9.window_end__month + , subq_9.window_end__quarter + , subq_9.window_end__year + , subq_9.window_end__extract_year + , subq_9.window_end__extract_quarter + , subq_9.window_end__extract_month + , subq_9.window_end__extract_day + , subq_9.window_end__extract_dow + , subq_9.window_end__extract_doy + , subq_9.lux_listing__window_start__day + , subq_9.lux_listing__window_start__week + , subq_9.lux_listing__window_start__month + , subq_9.lux_listing__window_start__quarter + , subq_9.lux_listing__window_start__year + , subq_9.lux_listing__window_start__extract_year + , subq_9.lux_listing__window_start__extract_quarter + , subq_9.lux_listing__window_start__extract_month + , subq_9.lux_listing__window_start__extract_day + , subq_9.lux_listing__window_start__extract_dow + , subq_9.lux_listing__window_start__extract_doy + , subq_9.lux_listing__window_end__day + , subq_9.lux_listing__window_end__week + , subq_9.lux_listing__window_end__month + , subq_9.lux_listing__window_end__quarter + , subq_9.lux_listing__window_end__year + , subq_9.lux_listing__window_end__extract_year + , subq_9.lux_listing__window_end__extract_quarter + , subq_9.lux_listing__window_end__extract_month + , subq_9.lux_listing__window_end__extract_day + , subq_9.lux_listing__window_end__extract_dow + , subq_9.lux_listing__window_end__extract_doy + , subq_9.lux_listing + , subq_9.is_confirmed_lux + , subq_9.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT - lux_listings_src_26004.valid_from AS window_start__day - , DATE_TRUNC(lux_listings_src_26004.valid_from, isoweek) AS window_start__week - , DATE_TRUNC(lux_listings_src_26004.valid_from, month) AS window_start__month - , DATE_TRUNC(lux_listings_src_26004.valid_from, quarter) AS window_start__quarter - , DATE_TRUNC(lux_listings_src_26004.valid_from, year) AS window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS window_start__extract_day - , IF(EXTRACT(dayofweek FROM lux_listings_src_26004.valid_from) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_26004.valid_from) - 1) AS window_start__extract_dow - , EXTRACT(dayofyear FROM lux_listings_src_26004.valid_from) AS window_start__extract_doy - , lux_listings_src_26004.valid_to AS window_end__day - , DATE_TRUNC(lux_listings_src_26004.valid_to, isoweek) AS window_end__week - , DATE_TRUNC(lux_listings_src_26004.valid_to, month) AS window_end__month - , DATE_TRUNC(lux_listings_src_26004.valid_to, quarter) AS window_end__quarter - , DATE_TRUNC(lux_listings_src_26004.valid_to, year) AS window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS window_end__extract_day - , IF(EXTRACT(dayofweek FROM lux_listings_src_26004.valid_to) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_26004.valid_to) - 1) AS window_end__extract_dow - , EXTRACT(dayofyear FROM lux_listings_src_26004.valid_to) AS window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux - , lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , DATE_TRUNC(lux_listings_src_26004.valid_from, isoweek) AS lux_listing__window_start__week - , DATE_TRUNC(lux_listings_src_26004.valid_from, month) AS lux_listing__window_start__month - , DATE_TRUNC(lux_listings_src_26004.valid_from, quarter) AS lux_listing__window_start__quarter - , DATE_TRUNC(lux_listings_src_26004.valid_from, year) AS lux_listing__window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_day - , IF(EXTRACT(dayofweek FROM lux_listings_src_26004.valid_from) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_26004.valid_from) - 1) AS lux_listing__window_start__extract_dow - , EXTRACT(dayofyear FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_doy - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , DATE_TRUNC(lux_listings_src_26004.valid_to, isoweek) AS lux_listing__window_end__week - , DATE_TRUNC(lux_listings_src_26004.valid_to, month) AS lux_listing__window_end__month - , DATE_TRUNC(lux_listings_src_26004.valid_to, quarter) AS lux_listing__window_end__quarter - , DATE_TRUNC(lux_listings_src_26004.valid_to, year) AS lux_listing__window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_day - , IF(EXTRACT(dayofweek FROM lux_listings_src_26004.valid_to) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_26004.valid_to) - 1) AS lux_listing__window_end__extract_dow - , EXTRACT(dayofyear FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - , lux_listings_src_26004.lux_listing_id AS lux_listing - FROM ***************************.dim_lux_listings lux_listings_src_26004 - ) subq_4 - ) subq_5 + lux_listings_src_26000.valid_from AS window_start__day + , DATE_TRUNC(lux_listings_src_26000.valid_from, isoweek) AS window_start__week + , DATE_TRUNC(lux_listings_src_26000.valid_from, month) AS window_start__month + , DATE_TRUNC(lux_listings_src_26000.valid_from, quarter) AS window_start__quarter + , DATE_TRUNC(lux_listings_src_26000.valid_from, year) AS window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS window_start__extract_day + , IF(EXTRACT(dayofweek FROM lux_listings_src_26000.valid_from) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_26000.valid_from) - 1) AS window_start__extract_dow + , EXTRACT(dayofyear FROM lux_listings_src_26000.valid_from) AS window_start__extract_doy + , lux_listings_src_26000.valid_to AS window_end__day + , DATE_TRUNC(lux_listings_src_26000.valid_to, isoweek) AS window_end__week + , DATE_TRUNC(lux_listings_src_26000.valid_to, month) AS window_end__month + , DATE_TRUNC(lux_listings_src_26000.valid_to, quarter) AS window_end__quarter + , DATE_TRUNC(lux_listings_src_26000.valid_to, year) AS window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS window_end__extract_day + , IF(EXTRACT(dayofweek FROM lux_listings_src_26000.valid_to) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_26000.valid_to) - 1) AS window_end__extract_dow + , EXTRACT(dayofyear FROM lux_listings_src_26000.valid_to) AS window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux + , lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , DATE_TRUNC(lux_listings_src_26000.valid_from, isoweek) AS lux_listing__window_start__week + , DATE_TRUNC(lux_listings_src_26000.valid_from, month) AS lux_listing__window_start__month + , DATE_TRUNC(lux_listings_src_26000.valid_from, quarter) AS lux_listing__window_start__quarter + , DATE_TRUNC(lux_listings_src_26000.valid_from, year) AS lux_listing__window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_day + , IF(EXTRACT(dayofweek FROM lux_listings_src_26000.valid_from) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_26000.valid_from) - 1) AS lux_listing__window_start__extract_dow + , EXTRACT(dayofyear FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_doy + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , DATE_TRUNC(lux_listings_src_26000.valid_to, isoweek) AS lux_listing__window_end__week + , DATE_TRUNC(lux_listings_src_26000.valid_to, month) AS lux_listing__window_end__month + , DATE_TRUNC(lux_listings_src_26000.valid_to, quarter) AS lux_listing__window_end__quarter + , DATE_TRUNC(lux_listings_src_26000.valid_to, year) AS lux_listing__window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_day + , IF(EXTRACT(dayofweek FROM lux_listings_src_26000.valid_to) = 1, 7, EXTRACT(dayofweek FROM lux_listings_src_26000.valid_to) - 1) AS lux_listing__window_end__extract_dow + , EXTRACT(dayofyear FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + , lux_listings_src_26000.lux_listing_id AS lux_listing + FROM ***************************.dim_lux_listings lux_listings_src_26000 + ) subq_9 + ) subq_10 ON - subq_3.lux_listing = subq_5.lux_listing - ) subq_6 - ) subq_7 + subq_8.lux_listing = subq_10.lux_listing + ) subq_11 + ) subq_12 ON ( - subq_2.listing = subq_7.listing + subq_7.listing = subq_12.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.lux_listing__window_start__day + subq_7.metric_time__day >= subq_12.lux_listing__window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.lux_listing__window_end__day + subq_7.metric_time__day < subq_12.lux_listing__window_end__day ) OR ( - subq_7.lux_listing__window_end__day IS NULL + subq_12.lux_listing__window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_13 + ) subq_14 GROUP BY metric_time__day , listing__lux_listing__is_confirmed_lux -) subq_10 +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql index 35253e96cb..65c658f3ed 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , SUM(subq_13.bookings) AS bookings + subq_18.metric_time__day AS metric_time__day + , subq_23.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_18.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,32 +15,32 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_18 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , lux_listing_mapping_src_26003.listing_id AS listing - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 + lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , lux_listing_mapping_src_26000.listing_id AS listing + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 LEFT OUTER JOIN - ***************************.dim_lux_listings lux_listings_src_26004 + ***************************.dim_lux_listings lux_listings_src_26000 ON - lux_listing_mapping_src_26003.lux_listing_id = lux_listings_src_26004.lux_listing_id -) subq_18 + lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id +) subq_23 ON ( - subq_13.listing = subq_18.listing + subq_18.listing = subq_23.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.lux_listing__window_start__day + subq_18.metric_time__day >= subq_23.lux_listing__window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.lux_listing__window_end__day + subq_18.metric_time__day < subq_23.lux_listing__window_end__day ) OR ( - subq_18.lux_listing__window_end__day IS NULL + subq_23.lux_listing__window_end__day IS NULL ) ) ) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql index 922b372419..020a476323 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql @@ -1,93 +1,93 @@ -- Compute Metrics via Expressions SELECT - subq_10.account_id__customer_id__customer_name - , subq_10.txn_count + subq_14.account_id__customer_id__customer_name + , subq_14.txn_count FROM ( -- Aggregate Measures SELECT - subq_9.account_id__customer_id__customer_name - , SUM(subq_9.txn_count) AS txn_count + subq_13.account_id__customer_id__customer_name + , SUM(subq_13.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_8.account_id__customer_id__customer_name - , subq_8.txn_count + subq_12.account_id__customer_id__customer_name + , subq_12.txn_count FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_2.account_id AS account_id - , subq_7.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_2.txn_count AS txn_count + subq_6.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_6.account_id AS account_id + , subq_11.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_6.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_1.ds_partitioned__day - , subq_1.account_id - , subq_1.txn_count + subq_5.ds_partitioned__day + , subq_5.account_id + , subq_5.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.account_id__ds_partitioned__day - , subq_0.account_id__ds_partitioned__week - , subq_0.account_id__ds_partitioned__month - , subq_0.account_id__ds_partitioned__quarter - , subq_0.account_id__ds_partitioned__year - , subq_0.account_id__ds_partitioned__extract_year - , subq_0.account_id__ds_partitioned__extract_quarter - , subq_0.account_id__ds_partitioned__extract_month - , subq_0.account_id__ds_partitioned__extract_day - , subq_0.account_id__ds_partitioned__extract_dow - , subq_0.account_id__ds_partitioned__extract_doy - , subq_0.account_id__ds__day - , subq_0.account_id__ds__week - , subq_0.account_id__ds__month - , subq_0.account_id__ds__quarter - , subq_0.account_id__ds__year - , subq_0.account_id__ds__extract_year - , subq_0.account_id__ds__extract_quarter - , subq_0.account_id__ds__extract_month - , subq_0.account_id__ds__extract_day - , subq_0.account_id__ds__extract_dow - , subq_0.account_id__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.account_id - , subq_0.account_month - , subq_0.account_id__account_month - , subq_0.txn_count + subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.account_id__ds_partitioned__day + , subq_4.account_id__ds_partitioned__week + , subq_4.account_id__ds_partitioned__month + , subq_4.account_id__ds_partitioned__quarter + , subq_4.account_id__ds_partitioned__year + , subq_4.account_id__ds_partitioned__extract_year + , subq_4.account_id__ds_partitioned__extract_quarter + , subq_4.account_id__ds_partitioned__extract_month + , subq_4.account_id__ds_partitioned__extract_day + , subq_4.account_id__ds_partitioned__extract_dow + , subq_4.account_id__ds_partitioned__extract_doy + , subq_4.account_id__ds__day + , subq_4.account_id__ds__week + , subq_4.account_id__ds__month + , subq_4.account_id__ds__quarter + , subq_4.account_id__ds__year + , subq_4.account_id__ds__extract_year + , subq_4.account_id__ds__extract_quarter + , subq_4.account_id__ds__extract_month + , subq_4.account_id__ds__extract_day + , subq_4.account_id__ds__extract_dow + , subq_4.account_id__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.account_id + , subq_4.account_month + , subq_4.account_id__account_month + , subq_4.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -140,118 +140,118 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_4 + ) subq_5 + ) subq_6 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_6.ds_partitioned__day - , subq_6.account_id - , subq_6.customer_id__customer_name + subq_10.ds_partitioned__day + , subq_10.account_id + , subq_10.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_3.ds_partitioned__day AS ds_partitioned__day - , subq_3.ds_partitioned__week AS ds_partitioned__week - , subq_3.ds_partitioned__month AS ds_partitioned__month - , subq_3.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_3.ds_partitioned__year AS ds_partitioned__year - , subq_3.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_3.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_3.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_3.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_3.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_3.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_3.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_3.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_3.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_3.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_3.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_3.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_3.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_5.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_5.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_5.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_5.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_5.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_5.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_3.account_id AS account_id - , subq_3.customer_id AS customer_id - , subq_3.account_id__customer_id AS account_id__customer_id - , subq_3.bridge_account__account_id AS bridge_account__account_id - , subq_3.bridge_account__customer_id AS bridge_account__customer_id - , subq_3.extra_dim AS extra_dim - , subq_3.account_id__extra_dim AS account_id__extra_dim - , subq_3.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_5.customer_name AS customer_id__customer_name - , subq_5.customer_atomic_weight AS customer_id__customer_atomic_weight + subq_7.ds_partitioned__day AS ds_partitioned__day + , subq_7.ds_partitioned__week AS ds_partitioned__week + , subq_7.ds_partitioned__month AS ds_partitioned__month + , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_7.ds_partitioned__year AS ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_9.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_9.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_9.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_9.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_9.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_9.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_7.account_id AS account_id + , subq_7.customer_id AS customer_id + , subq_7.account_id__customer_id AS account_id__customer_id + , subq_7.bridge_account__account_id AS bridge_account__account_id + , subq_7.bridge_account__customer_id AS bridge_account__customer_id + , subq_7.extra_dim AS extra_dim + , subq_7.account_id__extra_dim AS account_id__extra_dim + , subq_7.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_9.customer_name AS customer_id__customer_name + , subq_9.customer_atomic_weight AS customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT - bridge_table_src_22001.extra_dim - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bridge_table_src_22001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bridge_table_src_22001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS account_id__extra_dim - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, day) AS account_id__ds_partitioned__day - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, isoweek) AS account_id__ds_partitioned__week - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, month) AS account_id__ds_partitioned__month - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, year) AS account_id__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bridge_table_src_22001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bridge_table_src_22001.ds_partitioned) - 1) AS account_id__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS bridge_account__extra_dim - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, day) AS bridge_account__ds_partitioned__day - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, isoweek) AS bridge_account__ds_partitioned__week - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, month) AS bridge_account__ds_partitioned__month - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, quarter) AS bridge_account__ds_partitioned__quarter - , DATE_TRUNC(bridge_table_src_22001.ds_partitioned, year) AS bridge_account__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bridge_table_src_22001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bridge_table_src_22001.ds_partitioned) - 1) AS bridge_account__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy - , bridge_table_src_22001.account_id - , bridge_table_src_22001.customer_id - , bridge_table_src_22001.customer_id AS account_id__customer_id - , bridge_table_src_22001.account_id AS bridge_account__account_id - , bridge_table_src_22001.customer_id AS bridge_account__customer_id - FROM ***************************.bridge_table bridge_table_src_22001 - ) subq_3 + bridge_table_src_22000.extra_dim + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bridge_table_src_22000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bridge_table_src_22000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS account_id__extra_dim + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, day) AS account_id__ds_partitioned__day + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, isoweek) AS account_id__ds_partitioned__week + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, month) AS account_id__ds_partitioned__month + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, year) AS account_id__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bridge_table_src_22000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bridge_table_src_22000.ds_partitioned) - 1) AS account_id__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS bridge_account__extra_dim + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, day) AS bridge_account__ds_partitioned__day + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, isoweek) AS bridge_account__ds_partitioned__week + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, month) AS bridge_account__ds_partitioned__month + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, quarter) AS bridge_account__ds_partitioned__quarter + , DATE_TRUNC(bridge_table_src_22000.ds_partitioned, year) AS bridge_account__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bridge_table_src_22000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bridge_table_src_22000.ds_partitioned) - 1) AS bridge_account__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy + , bridge_table_src_22000.account_id + , bridge_table_src_22000.customer_id + , bridge_table_src_22000.customer_id AS account_id__customer_id + , bridge_table_src_22000.account_id AS bridge_account__account_id + , bridge_table_src_22000.customer_id AS bridge_account__customer_id + FROM ***************************.bridge_table bridge_table_src_22000 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -283,82 +283,82 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.customer_id__ds_partitioned__day - , subq_4.customer_id__ds_partitioned__week - , subq_4.customer_id__ds_partitioned__month - , subq_4.customer_id__ds_partitioned__quarter - , subq_4.customer_id__ds_partitioned__year - , subq_4.customer_id__ds_partitioned__extract_year - , subq_4.customer_id__ds_partitioned__extract_quarter - , subq_4.customer_id__ds_partitioned__extract_month - , subq_4.customer_id__ds_partitioned__extract_day - , subq_4.customer_id__ds_partitioned__extract_dow - , subq_4.customer_id__ds_partitioned__extract_doy - , subq_4.customer_id - , subq_4.customer_name - , subq_4.customer_atomic_weight - , subq_4.customer_id__customer_name - , subq_4.customer_id__customer_atomic_weight + subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.customer_id__ds_partitioned__day + , subq_8.customer_id__ds_partitioned__week + , subq_8.customer_id__ds_partitioned__month + , subq_8.customer_id__ds_partitioned__quarter + , subq_8.customer_id__ds_partitioned__year + , subq_8.customer_id__ds_partitioned__extract_year + , subq_8.customer_id__ds_partitioned__extract_quarter + , subq_8.customer_id__ds_partitioned__extract_month + , subq_8.customer_id__ds_partitioned__extract_day + , subq_8.customer_id__ds_partitioned__extract_dow + , subq_8.customer_id__ds_partitioned__extract_doy + , subq_8.customer_id + , subq_8.customer_name + , subq_8.customer_atomic_weight + , subq_8.customer_id__customer_name + , subq_8.customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT - customer_table_src_22003.customer_name - , customer_table_src_22003.customer_atomic_weight - , DATE_TRUNC(customer_table_src_22003.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(customer_table_src_22003.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(customer_table_src_22003.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(customer_table_src_22003.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(customer_table_src_22003.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM customer_table_src_22003.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM customer_table_src_22003.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_doy - , customer_table_src_22003.customer_name AS customer_id__customer_name - , customer_table_src_22003.customer_atomic_weight AS customer_id__customer_atomic_weight - , DATE_TRUNC(customer_table_src_22003.ds_partitioned, day) AS customer_id__ds_partitioned__day - , DATE_TRUNC(customer_table_src_22003.ds_partitioned, isoweek) AS customer_id__ds_partitioned__week - , DATE_TRUNC(customer_table_src_22003.ds_partitioned, month) AS customer_id__ds_partitioned__month - , DATE_TRUNC(customer_table_src_22003.ds_partitioned, quarter) AS customer_id__ds_partitioned__quarter - , DATE_TRUNC(customer_table_src_22003.ds_partitioned, year) AS customer_id__ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM customer_table_src_22003.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM customer_table_src_22003.ds_partitioned) - 1) AS customer_id__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_doy - , customer_table_src_22003.customer_id - FROM ***************************.customer_table customer_table_src_22003 - ) subq_4 - ) subq_5 + customer_table_src_22000.customer_name + , customer_table_src_22000.customer_atomic_weight + , DATE_TRUNC(customer_table_src_22000.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(customer_table_src_22000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(customer_table_src_22000.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(customer_table_src_22000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(customer_table_src_22000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM customer_table_src_22000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM customer_table_src_22000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , customer_table_src_22000.customer_name AS customer_id__customer_name + , customer_table_src_22000.customer_atomic_weight AS customer_id__customer_atomic_weight + , DATE_TRUNC(customer_table_src_22000.ds_partitioned, day) AS customer_id__ds_partitioned__day + , DATE_TRUNC(customer_table_src_22000.ds_partitioned, isoweek) AS customer_id__ds_partitioned__week + , DATE_TRUNC(customer_table_src_22000.ds_partitioned, month) AS customer_id__ds_partitioned__month + , DATE_TRUNC(customer_table_src_22000.ds_partitioned, quarter) AS customer_id__ds_partitioned__quarter + , DATE_TRUNC(customer_table_src_22000.ds_partitioned, year) AS customer_id__ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM customer_table_src_22000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM customer_table_src_22000.ds_partitioned) - 1) AS customer_id__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy + , customer_table_src_22000.customer_id + FROM ***************************.customer_table customer_table_src_22000 + ) subq_8 + ) subq_9 ON ( - subq_3.customer_id = subq_5.customer_id + subq_7.customer_id = subq_9.customer_id ) AND ( - subq_3.ds_partitioned__day = subq_5.ds_partitioned__day + subq_7.ds_partitioned__day = subq_9.ds_partitioned__day ) - ) subq_6 - ) subq_7 + ) subq_10 + ) subq_11 ON ( - subq_2.account_id = subq_7.account_id + subq_6.account_id = subq_11.account_id ) AND ( - subq_2.ds_partitioned__day = subq_7.ds_partitioned__day + subq_6.ds_partitioned__day = subq_11.ds_partitioned__day ) - ) subq_8 - ) subq_9 + ) subq_12 + ) subq_13 GROUP BY account_id__customer_id__customer_name -) subq_10 +) subq_14 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql index 57fc955213..ce26aa3779 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql @@ -3,31 +3,31 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_18.customer_id__customer_name AS account_id__customer_id__customer_name + subq_22.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - DATE_TRUNC(bridge_table_src_22001.ds_partitioned, day) AS ds_partitioned__day - , bridge_table_src_22001.account_id AS account_id - , customer_table_src_22003.customer_name AS customer_id__customer_name - FROM ***************************.bridge_table bridge_table_src_22001 + DATE_TRUNC(bridge_table_src_22000.ds_partitioned, day) AS ds_partitioned__day + , bridge_table_src_22000.account_id AS account_id + , customer_table_src_22000.customer_name AS customer_id__customer_name + FROM ***************************.bridge_table bridge_table_src_22000 LEFT OUTER JOIN - ***************************.customer_table customer_table_src_22003 + ***************************.customer_table customer_table_src_22000 ON ( - bridge_table_src_22001.customer_id = customer_table_src_22003.customer_id + bridge_table_src_22000.customer_id = customer_table_src_22000.customer_id ) AND ( - DATE_TRUNC(bridge_table_src_22001.ds_partitioned, day) = DATE_TRUNC(customer_table_src_22003.ds_partitioned, day) + DATE_TRUNC(bridge_table_src_22000.ds_partitioned, day) = DATE_TRUNC(customer_table_src_22000.ds_partitioned, day) ) -) subq_18 +) subq_22 ON ( - account_month_txns_src_22000.account_id = subq_18.account_id + account_month_txns_src_22000.account_id = subq_22.account_id ) AND ( - DATE_TRUNC(account_month_txns_src_22000.ds_partitioned, day) = subq_18.ds_partitioned__day + DATE_TRUNC(account_month_txns_src_22000.ds_partitioned, day) = subq_22.ds_partitioned__day ) GROUP BY account_id__customer_id__customer_name diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql index c22b96260b..d0f5edf4d8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql @@ -1,536 +1,536 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_5.bookings) AS bookings - , MAX(subq_11.listings) AS listings + MAX(subq_18.bookings) AS bookings + , MAX(subq_24.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_4.bookings + subq_17.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_3.bookings) AS bookings + SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_2.bookings + subq_15.bookings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.ds_partitioned__day - , subq_1.ds_partitioned__week - , subq_1.ds_partitioned__month - , subq_1.ds_partitioned__quarter - , subq_1.ds_partitioned__year - , subq_1.ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy - , subq_1.paid_at__day - , subq_1.paid_at__week - , subq_1.paid_at__month - , subq_1.paid_at__quarter - , subq_1.paid_at__year - , subq_1.paid_at__extract_year - , subq_1.paid_at__extract_quarter - , subq_1.paid_at__extract_month - , subq_1.paid_at__extract_day - , subq_1.paid_at__extract_dow - , subq_1.paid_at__extract_doy - , subq_1.booking__ds__day - , subq_1.booking__ds__week - , subq_1.booking__ds__month - , subq_1.booking__ds__quarter - , subq_1.booking__ds__year - , subq_1.booking__ds__extract_year - , subq_1.booking__ds__extract_quarter - , subq_1.booking__ds__extract_month - , subq_1.booking__ds__extract_day - , subq_1.booking__ds__extract_dow - , subq_1.booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day - , subq_1.booking__paid_at__week - , subq_1.booking__paid_at__month - , subq_1.booking__paid_at__quarter - , subq_1.booking__paid_at__year - , subq_1.booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.listing - , subq_1.guest - , subq_1.host - , subq_1.booking__listing - , subq_1.booking__guest - , subq_1.booking__host - , subq_1.is_instant - , subq_1.booking__is_instant - , subq_1.bookings - , subq_1.instant_bookings - , subq_1.booking_value - , subq_1.max_booking_value - , subq_1.min_booking_value - , subq_1.bookers - , subq_1.average_booking_value - , subq_1.referred_bookings - , subq_1.median_booking_value - , subq_1.booking_value_p99 - , subq_1.discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 + subq_14.ds__day + , subq_14.ds__week + , subq_14.ds__month + , subq_14.ds__quarter + , subq_14.ds__year + , subq_14.ds__extract_year + , subq_14.ds__extract_quarter + , subq_14.ds__extract_month + , subq_14.ds__extract_day + , subq_14.ds__extract_dow + , subq_14.ds__extract_doy + , subq_14.ds_partitioned__day + , subq_14.ds_partitioned__week + , subq_14.ds_partitioned__month + , subq_14.ds_partitioned__quarter + , subq_14.ds_partitioned__year + , subq_14.ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy + , subq_14.paid_at__day + , subq_14.paid_at__week + , subq_14.paid_at__month + , subq_14.paid_at__quarter + , subq_14.paid_at__year + , subq_14.paid_at__extract_year + , subq_14.paid_at__extract_quarter + , subq_14.paid_at__extract_month + , subq_14.paid_at__extract_day + , subq_14.paid_at__extract_dow + , subq_14.paid_at__extract_doy + , subq_14.booking__ds__day + , subq_14.booking__ds__week + , subq_14.booking__ds__month + , subq_14.booking__ds__quarter + , subq_14.booking__ds__year + , subq_14.booking__ds__extract_year + , subq_14.booking__ds__extract_quarter + , subq_14.booking__ds__extract_month + , subq_14.booking__ds__extract_day + , subq_14.booking__ds__extract_dow + , subq_14.booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day + , subq_14.booking__paid_at__week + , subq_14.booking__paid_at__month + , subq_14.booking__paid_at__quarter + , subq_14.booking__paid_at__year + , subq_14.booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy + , subq_14.metric_time__day + , subq_14.metric_time__week + , subq_14.metric_time__month + , subq_14.metric_time__quarter + , subq_14.metric_time__year + , subq_14.metric_time__extract_year + , subq_14.metric_time__extract_quarter + , subq_14.metric_time__extract_month + , subq_14.metric_time__extract_day + , subq_14.metric_time__extract_dow + , subq_14.metric_time__extract_doy + , subq_14.listing + , subq_14.guest + , subq_14.host + , subq_14.booking__listing + , subq_14.booking__guest + , subq_14.booking__host + , subq_14.is_instant + , subq_14.booking__is_instant + , subq_14.bookings + , subq_14.instant_bookings + , subq_14.booking_value + , subq_14.max_booking_value + , subq_14.min_booking_value + , subq_14.bookers + , subq_14.average_booking_value + , subq_14.referred_bookings + , subq_14.median_booking_value + , subq_14.booking_value_p99 + , subq_14.discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_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 + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.max_booking_value + , subq_13.min_booking_value + , subq_13.bookers + , subq_13.average_booking_value + , subq_13.referred_bookings + , subq_13.median_booking_value + , subq_13.booking_value_p99 + , subq_13.discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_2 - ) subq_3 - ) subq_4 -) subq_5 + , 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_13 + ) subq_14 + WHERE subq_14.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_15 + ) subq_16 + ) subq_17 +) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.listings + subq_23.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_9.listings) AS listings + SUM(subq_22.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_8.listings + subq_21.listings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] 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.created_at__day - , subq_7.created_at__week - , subq_7.created_at__month - , subq_7.created_at__quarter - , subq_7.created_at__year - , subq_7.created_at__extract_year - , subq_7.created_at__extract_quarter - , subq_7.created_at__extract_month - , subq_7.created_at__extract_day - , subq_7.created_at__extract_dow - , subq_7.created_at__extract_doy - , subq_7.listing__ds__day - , subq_7.listing__ds__week - , subq_7.listing__ds__month - , subq_7.listing__ds__quarter - , subq_7.listing__ds__year - , subq_7.listing__ds__extract_year - , subq_7.listing__ds__extract_quarter - , subq_7.listing__ds__extract_month - , subq_7.listing__ds__extract_day - , subq_7.listing__ds__extract_dow - , subq_7.listing__ds__extract_doy - , subq_7.listing__created_at__day - , subq_7.listing__created_at__week - , subq_7.listing__created_at__month - , subq_7.listing__created_at__quarter - , subq_7.listing__created_at__year - , subq_7.listing__created_at__extract_year - , subq_7.listing__created_at__extract_quarter - , subq_7.listing__created_at__extract_month - , subq_7.listing__created_at__extract_day - , subq_7.listing__created_at__extract_dow - , subq_7.listing__created_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.user - , subq_7.listing__user - , subq_7.country_latest - , subq_7.is_lux_latest - , subq_7.capacity_latest - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.listings - , subq_7.largest_listing - , subq_7.smallest_listing + 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.created_at__day + , subq_20.created_at__week + , subq_20.created_at__month + , subq_20.created_at__quarter + , subq_20.created_at__year + , subq_20.created_at__extract_year + , subq_20.created_at__extract_quarter + , subq_20.created_at__extract_month + , subq_20.created_at__extract_day + , subq_20.created_at__extract_dow + , subq_20.created_at__extract_doy + , subq_20.listing__ds__day + , subq_20.listing__ds__week + , subq_20.listing__ds__month + , subq_20.listing__ds__quarter + , subq_20.listing__ds__year + , subq_20.listing__ds__extract_year + , subq_20.listing__ds__extract_quarter + , subq_20.listing__ds__extract_month + , subq_20.listing__ds__extract_day + , subq_20.listing__ds__extract_dow + , subq_20.listing__ds__extract_doy + , subq_20.listing__created_at__day + , subq_20.listing__created_at__week + , subq_20.listing__created_at__month + , subq_20.listing__created_at__quarter + , subq_20.listing__created_at__year + , subq_20.listing__created_at__extract_year + , subq_20.listing__created_at__extract_quarter + , subq_20.listing__created_at__extract_month + , subq_20.listing__created_at__extract_day + , subq_20.listing__created_at__extract_dow + , subq_20.listing__created_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.user + , subq_20.listing__user + , subq_20.country_latest + , subq_20.is_lux_latest + , subq_20.capacity_latest + , subq_20.listing__country_latest + , subq_20.listing__is_lux_latest + , subq_20.listing__capacity_latest + , subq_20.listings + , subq_20.largest_listing + , subq_20.smallest_listing FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_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.created_at__day + , subq_19.created_at__week + , subq_19.created_at__month + , subq_19.created_at__quarter + , subq_19.created_at__year + , subq_19.created_at__extract_year + , subq_19.created_at__extract_quarter + , subq_19.created_at__extract_month + , subq_19.created_at__extract_day + , subq_19.created_at__extract_dow + , subq_19.created_at__extract_doy + , subq_19.listing__ds__day + , subq_19.listing__ds__week + , subq_19.listing__ds__month + , subq_19.listing__ds__quarter + , subq_19.listing__ds__year + , subq_19.listing__ds__extract_year + , subq_19.listing__ds__extract_quarter + , subq_19.listing__ds__extract_month + , subq_19.listing__ds__extract_day + , subq_19.listing__ds__extract_dow + , subq_19.listing__ds__extract_doy + , subq_19.listing__created_at__day + , subq_19.listing__created_at__week + , subq_19.listing__created_at__month + , subq_19.listing__created_at__quarter + , subq_19.listing__created_at__year + , subq_19.listing__created_at__extract_year + , subq_19.listing__created_at__extract_quarter + , subq_19.listing__created_at__extract_month + , subq_19.listing__created_at__extract_day + , subq_19.listing__created_at__extract_dow + , subq_19.listing__created_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.user + , subq_19.listing__user + , subq_19.country_latest + , subq_19.is_lux_latest + , subq_19.capacity_latest + , subq_19.listing__country_latest + , subq_19.listing__is_lux_latest + , subq_19.listing__capacity_latest + , subq_19.listings + , subq_19.largest_listing + , subq_19.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28005.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28005.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28005.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28005.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28005.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28005.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_6 - ) subq_7 - WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_8 - ) subq_9 - ) subq_10 -) subq_11 + , 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_19 + ) subq_20 + WHERE subq_20.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_21 + ) subq_22 + ) subq_23 +) subq_24 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 2c8f47874d..e78696f79f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_17.bookings) AS bookings - , MAX(subq_23.listings) AS listings + MAX(subq_30.bookings) AS bookings + , MAX(subq_36.listings) AS listings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -11,9 +11,9 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC(ds, day) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_17 +) subq_30 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -23,6 +23,6 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 WHERE DATE_TRUNC(created_at, day) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_23 +) subq_36 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql index 0c355fc5a3..a785393c2c 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql @@ -1,241 +1,241 @@ -- Compute Metrics via Expressions SELECT - subq_7.user__home_state - , subq_7.identity_verifications + subq_16.user__home_state + , subq_16.identity_verifications FROM ( -- Aggregate Measures SELECT - subq_6.user__home_state - , SUM(subq_6.identity_verifications) AS identity_verifications + subq_15.user__home_state + , SUM(subq_15.identity_verifications) AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'user__home_state'] SELECT - subq_5.user__home_state - , subq_5.identity_verifications + subq_14.user__home_state + , subq_14.identity_verifications FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__day AS user__ds_partitioned__day - , subq_2.user AS user - , subq_4.home_state AS user__home_state - , subq_2.identity_verifications AS identity_verifications + subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__day AS user__ds_partitioned__day + , subq_11.user AS user + , subq_13.home_state AS user__home_state + , subq_11.identity_verifications AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT - subq_1.ds_partitioned__day - , subq_1.user - , subq_1.identity_verifications + subq_10.ds_partitioned__day + , subq_10.user + , subq_10.identity_verifications 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.verification__ds__day - , subq_0.verification__ds__week - , subq_0.verification__ds__month - , subq_0.verification__ds__quarter - , subq_0.verification__ds__year - , subq_0.verification__ds__extract_year - , subq_0.verification__ds__extract_quarter - , subq_0.verification__ds__extract_month - , subq_0.verification__ds__extract_day - , subq_0.verification__ds__extract_dow - , subq_0.verification__ds__extract_doy - , subq_0.verification__ds_partitioned__day - , subq_0.verification__ds_partitioned__week - , subq_0.verification__ds_partitioned__month - , subq_0.verification__ds_partitioned__quarter - , subq_0.verification__ds_partitioned__year - , subq_0.verification__ds_partitioned__extract_year - , subq_0.verification__ds_partitioned__extract_quarter - , subq_0.verification__ds_partitioned__extract_month - , subq_0.verification__ds_partitioned__extract_day - , subq_0.verification__ds_partitioned__extract_dow - , subq_0.verification__ds_partitioned__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.verification - , subq_0.user - , subq_0.verification__user - , subq_0.verification_type - , subq_0.verification__verification_type - , subq_0.identity_verifications + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.verification__ds__day + , subq_9.verification__ds__week + , subq_9.verification__ds__month + , subq_9.verification__ds__quarter + , subq_9.verification__ds__year + , subq_9.verification__ds__extract_year + , subq_9.verification__ds__extract_quarter + , subq_9.verification__ds__extract_month + , subq_9.verification__ds__extract_day + , subq_9.verification__ds__extract_dow + , subq_9.verification__ds__extract_doy + , subq_9.verification__ds_partitioned__day + , subq_9.verification__ds_partitioned__week + , subq_9.verification__ds_partitioned__month + , subq_9.verification__ds_partitioned__quarter + , subq_9.verification__ds_partitioned__year + , subq_9.verification__ds_partitioned__extract_year + , subq_9.verification__ds_partitioned__extract_quarter + , subq_9.verification__ds_partitioned__extract_month + , subq_9.verification__ds_partitioned__extract_day + , subq_9.verification__ds_partitioned__extract_dow + , subq_9.verification__ds_partitioned__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.verification + , subq_9.user + , subq_9.verification__user + , subq_9.verification_type + , subq_9.verification__verification_type + , subq_9.identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC(id_verifications_src_28004.ds, day) AS ds__day - , DATE_TRUNC(id_verifications_src_28004.ds, isoweek) AS ds__week - , DATE_TRUNC(id_verifications_src_28004.ds, month) AS ds__month - , DATE_TRUNC(id_verifications_src_28004.ds, quarter) AS ds__quarter - , DATE_TRUNC(id_verifications_src_28004.ds, year) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_28004.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28004.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_28004.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28004.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC(id_verifications_src_28004.ds, day) AS verification__ds__day - , DATE_TRUNC(id_verifications_src_28004.ds, isoweek) AS verification__ds__week - , DATE_TRUNC(id_verifications_src_28004.ds, month) AS verification__ds__month - , DATE_TRUNC(id_verifications_src_28004.ds, quarter) AS verification__ds__quarter - , DATE_TRUNC(id_verifications_src_28004.ds, year) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_28004.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28004.ds) - 1) AS verification__ds__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, day) AS verification__ds_partitioned__day - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, isoweek) AS verification__ds_partitioned__week - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, month) AS verification__ds_partitioned__month - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, quarter) AS verification__ds_partitioned__quarter - , DATE_TRUNC(id_verifications_src_28004.ds_partitioned, year) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM id_verifications_src_28004.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28004.ds_partitioned) - 1) AS verification__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user - FROM ***************************.fct_id_verifications id_verifications_src_28004 - ) subq_0 - ) subq_1 - ) subq_2 + , DATE_TRUNC(id_verifications_src_28000.ds, day) AS ds__day + , DATE_TRUNC(id_verifications_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(id_verifications_src_28000.ds, month) AS ds__month + , DATE_TRUNC(id_verifications_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(id_verifications_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC(id_verifications_src_28000.ds, day) AS verification__ds__day + , DATE_TRUNC(id_verifications_src_28000.ds, isoweek) AS verification__ds__week + , DATE_TRUNC(id_verifications_src_28000.ds, month) AS verification__ds__month + , DATE_TRUNC(id_verifications_src_28000.ds, quarter) AS verification__ds__quarter + , DATE_TRUNC(id_verifications_src_28000.ds, year) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28000.ds) - 1) AS verification__ds__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, day) AS verification__ds_partitioned__day + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, isoweek) AS verification__ds_partitioned__week + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, month) AS verification__ds_partitioned__month + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, quarter) AS verification__ds_partitioned__quarter + , DATE_TRUNC(id_verifications_src_28000.ds_partitioned, year) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM id_verifications_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM id_verifications_src_28000.ds_partitioned) - 1) AS verification__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user + FROM ***************************.fct_id_verifications id_verifications_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state', 'ds_partitioned__day', 'user'] SELECT - subq_3.ds_partitioned__day - , subq_3.user - , subq_3.home_state + subq_12.ds_partitioned__day + , subq_12.user + , subq_12.home_state FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - DATE_TRUNC(users_ds_source_src_28008.ds, day) AS ds__day - , DATE_TRUNC(users_ds_source_src_28008.ds, isoweek) AS ds__week - , DATE_TRUNC(users_ds_source_src_28008.ds, month) AS ds__month - , DATE_TRUNC(users_ds_source_src_28008.ds, quarter) AS ds__quarter - , DATE_TRUNC(users_ds_source_src_28008.ds, year) AS ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28008.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28008.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28008.ds) AS ds__extract_doy - , DATE_TRUNC(users_ds_source_src_28008.created_at, day) AS created_at__day - , DATE_TRUNC(users_ds_source_src_28008.created_at, isoweek) AS created_at__week - , DATE_TRUNC(users_ds_source_src_28008.created_at, month) AS created_at__month - , DATE_TRUNC(users_ds_source_src_28008.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(users_ds_source_src_28008.created_at, year) AS created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28008.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28008.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28008.created_at) AS created_at__extract_doy - , DATE_TRUNC(users_ds_source_src_28008.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(users_ds_source_src_28008.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(users_ds_source_src_28008.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(users_ds_source_src_28008.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(users_ds_source_src_28008.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28008.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28008.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state - , DATE_TRUNC(users_ds_source_src_28008.ds, day) AS user__ds__day - , DATE_TRUNC(users_ds_source_src_28008.ds, isoweek) AS user__ds__week - , DATE_TRUNC(users_ds_source_src_28008.ds, month) AS user__ds__month - , DATE_TRUNC(users_ds_source_src_28008.ds, quarter) AS user__ds__quarter - , DATE_TRUNC(users_ds_source_src_28008.ds, year) AS user__ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS user__ds__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28008.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28008.ds) - 1) AS user__ds__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28008.ds) AS user__ds__extract_doy - , DATE_TRUNC(users_ds_source_src_28008.created_at, day) AS user__created_at__day - , DATE_TRUNC(users_ds_source_src_28008.created_at, isoweek) AS user__created_at__week - , DATE_TRUNC(users_ds_source_src_28008.created_at, month) AS user__created_at__month - , DATE_TRUNC(users_ds_source_src_28008.created_at, quarter) AS user__created_at__quarter - , DATE_TRUNC(users_ds_source_src_28008.created_at, year) AS user__created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28008.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28008.created_at) - 1) AS user__created_at__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_doy - , DATE_TRUNC(users_ds_source_src_28008.ds_partitioned, day) AS user__ds_partitioned__day - , DATE_TRUNC(users_ds_source_src_28008.ds_partitioned, isoweek) AS user__ds_partitioned__week - , DATE_TRUNC(users_ds_source_src_28008.ds_partitioned, month) AS user__ds_partitioned__month - , DATE_TRUNC(users_ds_source_src_28008.ds_partitioned, quarter) AS user__ds_partitioned__quarter - , DATE_TRUNC(users_ds_source_src_28008.ds_partitioned, year) AS user__ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28008.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28008.ds_partitioned) - 1) AS user__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state AS user__home_state - , users_ds_source_src_28008.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28008 - ) subq_3 - ) subq_4 + DATE_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(users_ds_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(users_ds_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC(users_ds_source_src_28000.created_at, day) AS created_at__day + , DATE_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS created_at__week + , DATE_TRUNC(users_ds_source_src_28000.created_at, month) AS created_at__month + , DATE_TRUNC(users_ds_source_src_28000.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(users_ds_source_src_28000.created_at, year) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(users_ds_source_src_28000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC(users_ds_source_src_28000.ds, day) AS user__ds__day + , DATE_TRUNC(users_ds_source_src_28000.ds, isoweek) AS user__ds__week + , DATE_TRUNC(users_ds_source_src_28000.ds, month) AS user__ds__month + , DATE_TRUNC(users_ds_source_src_28000.ds, quarter) AS user__ds__quarter + , DATE_TRUNC(users_ds_source_src_28000.ds, year) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) - 1) AS user__ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC(users_ds_source_src_28000.created_at, day) AS user__created_at__day + , DATE_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS user__created_at__week + , DATE_TRUNC(users_ds_source_src_28000.created_at, month) AS user__created_at__month + , DATE_TRUNC(users_ds_source_src_28000.created_at, quarter) AS user__created_at__quarter + , DATE_TRUNC(users_ds_source_src_28000.created_at, year) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) - 1) AS user__created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS user__ds_partitioned__day + , DATE_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS user__ds_partitioned__week + , DATE_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS user__ds_partitioned__month + , DATE_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS user__ds_partitioned__quarter + , DATE_TRUNC(users_ds_source_src_28000.ds_partitioned, year) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) - 1) AS user__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_12 + ) subq_13 ON ( - subq_2.user = subq_4.user + subq_11.user = subq_13.user ) AND ( - subq_2.ds_partitioned__day = subq_4.ds_partitioned__day + subq_11.ds_partitioned__day = subq_13.ds_partitioned__day ) - ) subq_5 - ) subq_6 + ) subq_14 + ) subq_15 GROUP BY user__home_state -) subq_7 +) subq_16 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql index a37ab6164a..8f1f60d7af 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql @@ -3,8 +3,8 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - users_ds_source_src_28008.home_state AS user__home_state - , SUM(subq_10.identity_verifications) AS identity_verifications + users_ds_source_src_28000.home_state AS user__home_state + , SUM(subq_19.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' -- Metric Time Dimension 'ds' @@ -13,15 +13,15 @@ FROM ( DATE_TRUNC(ds_partitioned, day) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications - FROM ***************************.fct_id_verifications id_verifications_src_28004 -) subq_10 + FROM ***************************.fct_id_verifications id_verifications_src_28000 +) subq_19 LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_28008 + ***************************.dim_users users_ds_source_src_28000 ON ( - subq_10.user = users_ds_source_src_28008.user_id + subq_19.user = users_ds_source_src_28000.user_id ) AND ( - subq_10.ds_partitioned__day = DATE_TRUNC(users_ds_source_src_28008.ds_partitioned, day) + subq_19.ds_partitioned__day = DATE_TRUNC(users_ds_source_src_28000.ds_partitioned, day) ) GROUP BY user__home_state diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0.sql index 7734b8a156..1b52dc6b2e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0.sql @@ -1,439 +1,439 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_value) AS booking_value + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 -) subq_4 + subq_11.metric_time__day + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_value) AS booking_value + subq_16.metric_time__day + , SUM(subq_16.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_value + subq_15.metric_time__day + , subq_15.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_16.metric_time__day + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0_optimized.sql index ccc0d8cd89..7831d40fe6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql index 438bee63bc..e9ee0c5d30 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql @@ -68,62 +68,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0_optimized.sql index 22b719da85..1653ada5bd 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_3 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql index 36e7aa5354..590fbcf5f8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -1,383 +1,383 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_19.booking__is_instant + , subq_19.bookings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_18.booking__is_instant + , SUM(subq_18.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_17.booking__is_instant + , subq_17.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_16.booking__is_instant + , subq_16.listing__country_latest + , subq_16.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.booking__is_instant + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.listing + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__country_latest = 'us' - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_18.booking__is_instant +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index fdbb61ce0e..433c9799b5 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.country AS listing__country_latest - , subq_13.bookings AS bookings + subq_22.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.country AS listing__country_latest + , subq_22.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -20,13 +20,13 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28005.listing_id -) subq_18 + subq_22.listing = listings_latest_src_28000.listing_id +) subq_27 WHERE listing__country_latest = 'us' GROUP BY booking__is_instant diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql index 2065f841d1..c776e48c51 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql @@ -1,139 +1,139 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS family_bookings + subq_11.metric_time__day + , subq_11.bookings AS family_bookings FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_10.metric_time__day + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.listing__capacity - , subq_6.bookings + subq_8.metric_time__day + , subq_8.listing__capacity + , subq_8.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.listing__capacity - , subq_5.bookings + subq_7.metric_time__day + , subq_7.listing__capacity + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_4.window_start__day AS listing__window_start__day - , subq_4.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_4.capacity AS listing__capacity - , subq_2.bookings AS bookings + subq_4.metric_time__day AS metric_time__day + , subq_6.window_start__day AS listing__window_start__day + , subq_6.window_end__day AS listing__window_end__day + , subq_4.listing AS listing + , subq_6.capacity AS listing__capacity + , subq_4.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_3.metric_time__day + , subq_3.listing + , subq_3.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + 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.user + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.booking__user + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.bookers + , subq_2.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -220,94 +220,94 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_2 + ) subq_3 + ) subq_4 LEFT OUTER JOIN ( -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_3.window_start__day - , subq_3.window_end__day - , subq_3.listing - , subq_3.capacity + subq_5.window_start__day + , subq_5.window_end__day + , subq_5.listing + , subq_5.capacity FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26002.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26002.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26002.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26002.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 - ) subq_4 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26000.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26000.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26000.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26000.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_4.listing + subq_4.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_4.window_start__day + subq_4.metric_time__day >= subq_6.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_4.window_end__day + subq_4.metric_time__day < subq_6.window_end__day ) OR ( - subq_4.window_end__day IS NULL + subq_6.window_end__day IS NULL ) ) ) - ) subq_5 - ) subq_6 + ) subq_7 + ) subq_8 WHERE listing__capacity > 2 - ) subq_7 - ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_8.metric_time__day -) subq_9 + subq_10.metric_time__day +) subq_11 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql index fc848091b1..0f3bd95cd6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_12.metric_time__day AS metric_time__day - , listings_src_26002.capacity AS listing__capacity - , subq_12.bookings AS bookings + subq_14.metric_time__day AS metric_time__day + , listings_src_26000.capacity AS listing__capacity + , subq_14.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -21,24 +21,24 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_12 + ) subq_14 LEFT OUTER JOIN - ***************************.dim_listings listings_src_26002 + ***************************.dim_listings listings_src_26000 ON ( - subq_12.listing = listings_src_26002.listing_id + subq_14.listing = listings_src_26000.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_26002.active_from + subq_14.metric_time__day >= listings_src_26000.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_26002.active_to + subq_14.metric_time__day < listings_src_26000.active_to ) OR ( - listings_src_26002.active_to IS NULL + listings_src_26000.active_to IS NULL ) ) ) -) subq_16 +) subq_18 WHERE listing__capacity > 2 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_limit_rows__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_limit_rows__plan0.sql index 8509c1b208..366e25c578 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_limit_rows__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_limit_rows__plan0.sql @@ -1,220 +1,220 @@ -- Order By [] Limit 1 SELECT - subq_4.ds__day - , subq_4.bookings + subq_13.ds__day + , subq_13.bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.bookings + subq_12.ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.bookings + subq_10.ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__day - ) subq_3 -) subq_4 + subq_11.ds__day + ) subq_12 +) subq_13 LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_limit_rows__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_limit_rows__plan0_optimized.sql index a71f7ae0e8..0780ad9c07 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_limit_rows__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_limit_rows__plan0_optimized.sql @@ -11,8 +11,8 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_7 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_16 GROUP BY ds__day LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0.sql index e560e7c411..acff3e3465 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0.sql @@ -1,150 +1,150 @@ -- Compute Metrics via Expressions SELECT - subq_3.listing__country_latest - , subq_3.listings + subq_12.listing__country_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_2.listing__country_latest - , SUM(subq_2.listings) AS listings + subq_11.listing__country_latest + , SUM(subq_11.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'listing__country_latest'] SELECT - subq_1.listing__country_latest - , subq_1.listings + subq_10.listing__country_latest + , subq_10.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.created_at__day - , subq_0.created_at__week - , subq_0.created_at__month - , subq_0.created_at__quarter - , subq_0.created_at__year - , subq_0.created_at__extract_year - , subq_0.created_at__extract_quarter - , subq_0.created_at__extract_month - , subq_0.created_at__extract_day - , subq_0.created_at__extract_dow - , subq_0.created_at__extract_doy - , subq_0.listing__ds__day - , subq_0.listing__ds__week - , subq_0.listing__ds__month - , subq_0.listing__ds__quarter - , subq_0.listing__ds__year - , subq_0.listing__ds__extract_year - , subq_0.listing__ds__extract_quarter - , subq_0.listing__ds__extract_month - , subq_0.listing__ds__extract_day - , subq_0.listing__ds__extract_dow - , subq_0.listing__ds__extract_doy - , subq_0.listing__created_at__day - , subq_0.listing__created_at__week - , subq_0.listing__created_at__month - , subq_0.listing__created_at__quarter - , subq_0.listing__created_at__year - , subq_0.listing__created_at__extract_year - , subq_0.listing__created_at__extract_quarter - , subq_0.listing__created_at__extract_month - , subq_0.listing__created_at__extract_day - , subq_0.listing__created_at__extract_dow - , subq_0.listing__created_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.user - , subq_0.listing__user - , subq_0.country_latest - , subq_0.is_lux_latest - , subq_0.capacity_latest - , subq_0.listing__country_latest - , subq_0.listing__is_lux_latest - , subq_0.listing__capacity_latest - , subq_0.listings - , subq_0.largest_listing - , subq_0.smallest_listing + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.listing__country_latest -) subq_3 + subq_11.listing__country_latest +) subq_12 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0_optimized.sql index 8486e86449..c0733d39a6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT country AS listing__country_latest , 1 AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_6 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_15 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql index b39ef66d2b..1724a1ca6d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql @@ -1,1003 +1,1003 @@ -- Compute Metrics via Expressions SELECT - subq_29.metric_time__day + subq_38.metric_time__day , average_booking_value * bookings / NULLIF(booking_value, 0) AS lux_booking_value_rate_expr FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_28.booking_value) AS booking_value + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_37.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_19.metric_time__day + , subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , AVG(subq_9.average_booking_value) AS average_booking_value + subq_18.metric_time__day + , AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_17.metric_time__day + , subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.metric_time__day + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.metric_time__day + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.average_booking_value AS average_booking_value + subq_11.metric_time__day AS metric_time__day + , subq_11.listing AS listing + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.average_booking_value + subq_10.metric_time__day + , subq_10.listing + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_18.metric_time__day + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day - , subq_22.bookings + subq_31.metric_time__day + , subq_31.bookings FROM ( -- Aggregate Measures SELECT - subq_21.metric_time__day - , SUM(subq_21.bookings) AS bookings + subq_30.metric_time__day + , SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.metric_time__day + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.metric_time__day + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.metric_time__day AS metric_time__day + , subq_23.listing AS listing + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.bookings + subq_22.metric_time__day + , subq_22.listing + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE listing__is_lux_latest - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 GROUP BY - subq_21.metric_time__day - ) subq_22 - ) subq_23 + subq_30.metric_time__day + ) subq_31 + ) subq_32 ON - subq_11.metric_time__day = subq_23.metric_time__day + subq_20.metric_time__day = subq_32.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.booking_value + subq_36.metric_time__day + , subq_36.booking_value FROM ( -- Aggregate Measures SELECT - subq_26.metric_time__day - , SUM(subq_26.booking_value) AS booking_value + subq_35.metric_time__day + , SUM(subq_35.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_25.metric_time__day - , subq_25.booking_value + subq_34.metric_time__day + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 GROUP BY - subq_26.metric_time__day - ) subq_27 - ) subq_28 + subq_35.metric_time__day + ) subq_36 + ) subq_37 ON - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day) = subq_37.metric_time__day GROUP BY - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) -) subq_29 + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day, subq_37.metric_time__day) +) subq_38 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql index 69ba3892a2..91ab825138 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) AS metric_time__day - , MAX(subq_41.average_booking_value) AS average_booking_value - , MAX(subq_53.bookings) AS bookings - , MAX(subq_58.booking_value) AS booking_value + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day, subq_67.metric_time__day) AS metric_time__day + , MAX(subq_50.average_booking_value) AS average_booking_value + , MAX(subq_62.bookings) AS bookings + , MAX(subq_67.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -21,19 +21,19 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - DATE_TRUNC('day', bookings_source_src_28001.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + DATE_TRUNC('day', bookings_source_src_28000.ds) AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_37 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_46 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_41 + ) subq_50 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -46,9 +46,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_44.metric_time__day AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_44.bookings AS bookings + subq_53.metric_time__day AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_53.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -57,19 +57,19 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_44 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_53 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_44.listing = listings_latest_src_28005.listing_id - ) subq_49 + subq_53.listing = listings_latest_src_28000.listing_id + ) subq_58 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_53 + ) subq_62 ON - subq_41.metric_time__day = subq_53.metric_time__day + subq_50.metric_time__day = subq_62.metric_time__day FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -79,12 +79,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_58 + ) subq_67 ON - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day) = subq_58.metric_time__day + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day) = subq_67.metric_time__day GROUP BY - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) -) subq_59 + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day, subq_67.metric_time__day) +) subq_68 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql index 7ab61ee90b..375ec870ed 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,460 +1,460 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , CAST(subq_12.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_12.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio + subq_21.metric_time__day + , CAST(subq_21.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_21.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , MAX(subq_6.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_11.booking_value) AS booking_value + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day + , MAX(subq_15.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_20.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.booking_value AS booking_value_with_is_instant_constraint + subq_14.metric_time__day + , subq_14.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.booking_value) AS booking_value + subq_13.metric_time__day + , SUM(subq_13.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.booking_value + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_13.metric_time__day + ) subq_14 + ) subq_15 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_19.metric_time__day + , subq_19.booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.booking_value) AS booking_value + subq_18.metric_time__day + , SUM(subq_18.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.ds_partitioned__day + , subq_16.ds_partitioned__week + , subq_16.ds_partitioned__month + , subq_16.ds_partitioned__quarter + , subq_16.ds_partitioned__year + , subq_16.ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy + , subq_16.paid_at__day + , subq_16.paid_at__week + , subq_16.paid_at__month + , subq_16.paid_at__quarter + , subq_16.paid_at__year + , subq_16.paid_at__extract_year + , subq_16.paid_at__extract_quarter + , subq_16.paid_at__extract_month + , subq_16.paid_at__extract_day + , subq_16.paid_at__extract_dow + , subq_16.paid_at__extract_doy + , subq_16.booking__ds__day + , subq_16.booking__ds__week + , subq_16.booking__ds__month + , subq_16.booking__ds__quarter + , subq_16.booking__ds__year + , subq_16.booking__ds__extract_year + , subq_16.booking__ds__extract_quarter + , subq_16.booking__ds__extract_month + , subq_16.booking__ds__extract_day + , subq_16.booking__ds__extract_dow + , subq_16.booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day + , subq_16.booking__paid_at__week + , subq_16.booking__paid_at__month + , subq_16.booking__paid_at__quarter + , subq_16.booking__paid_at__year + , subq_16.booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.listing + , subq_16.guest + , subq_16.host + , subq_16.booking__listing + , subq_16.booking__guest + , subq_16.booking__host + , subq_16.is_instant + , subq_16.booking__is_instant + , subq_16.bookings + , subq_16.instant_bookings + , subq_16.booking_value + , subq_16.max_booking_value + , subq_16.min_booking_value + , subq_16.bookers + , subq_16.average_booking_value + , subq_16.referred_bookings + , subq_16.median_booking_value + , subq_16.booking_value_p99 + , subq_16.discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 + , subq_16.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_7 - ) subq_8 - ) subq_9 + , 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_16 + ) subq_17 + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_18.metric_time__day + ) subq_19 + ) subq_20 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_15.metric_time__day = subq_20.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) +) subq_21 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql index d384201243..e6c18549b2 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/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_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , MAX(subq_19.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_24.booking_value) AS booking_value + COALESCE(subq_28.metric_time__day, subq_33.metric_time__day) AS metric_time__day + , MAX(subq_28.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_33.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_28 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -39,12 +39,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_33 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_28.metric_time__day = subq_33.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_28.metric_time__day, subq_33.metric_time__day) +) subq_34 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql index c3f735c506..16495e8981 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,234 +1,234 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day + subq_15.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.bookings AS delayed_bookings + subq_14.metric_time__day + , subq_14.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_13.metric_time__day + , SUM(subq_13.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE NOT booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY - subq_4.metric_time__day - ) subq_5 -) subq_6 + subq_13.metric_time__day + ) subq_14 +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index df414b0013..c494772d25 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -18,9 +18,9 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 145648b100..5551bce579 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -1,366 +1,366 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_10.bookings AS DOUBLE) / CAST(NULLIF(subq_10.listings, 0) AS DOUBLE) AS bookings_per_listing + CAST(subq_19.bookings AS DOUBLE) / CAST(NULLIF(subq_19.listings, 0) AS DOUBLE) AS bookings_per_listing FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_4.bookings) AS bookings - , MAX(subq_9.listings) AS listings + MAX(subq_13.bookings) AS bookings + , MAX(subq_18.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.bookings + subq_12.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_2.bookings) AS bookings + SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_1.bookings + subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 - ) subq_4 + , 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_9 + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.listings + subq_17.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_7.listings) AS listings + SUM(subq_16.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_6.listings + subq_15.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.created_at__day - , subq_5.created_at__week - , subq_5.created_at__month - , subq_5.created_at__quarter - , subq_5.created_at__year - , subq_5.created_at__extract_year - , subq_5.created_at__extract_quarter - , subq_5.created_at__extract_month - , subq_5.created_at__extract_day - , subq_5.created_at__extract_dow - , subq_5.created_at__extract_doy - , subq_5.listing__ds__day - , subq_5.listing__ds__week - , subq_5.listing__ds__month - , subq_5.listing__ds__quarter - , subq_5.listing__ds__year - , subq_5.listing__ds__extract_year - , subq_5.listing__ds__extract_quarter - , subq_5.listing__ds__extract_month - , subq_5.listing__ds__extract_day - , subq_5.listing__ds__extract_dow - , subq_5.listing__ds__extract_doy - , subq_5.listing__created_at__day - , subq_5.listing__created_at__week - , subq_5.listing__created_at__month - , subq_5.listing__created_at__quarter - , subq_5.listing__created_at__year - , subq_5.listing__created_at__extract_year - , subq_5.listing__created_at__extract_quarter - , subq_5.listing__created_at__extract_month - , subq_5.listing__created_at__extract_day - , subq_5.listing__created_at__extract_dow - , subq_5.listing__created_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.user - , subq_5.listing__user - , subq_5.country_latest - , subq_5.is_lux_latest - , subq_5.capacity_latest - , subq_5.listing__country_latest - , subq_5.listing__is_lux_latest - , subq_5.listing__capacity_latest - , subq_5.listings - , subq_5.largest_listing - , subq_5.smallest_listing + 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.created_at__day + , subq_14.created_at__week + , subq_14.created_at__month + , subq_14.created_at__quarter + , subq_14.created_at__year + , subq_14.created_at__extract_year + , subq_14.created_at__extract_quarter + , subq_14.created_at__extract_month + , subq_14.created_at__extract_day + , subq_14.created_at__extract_dow + , subq_14.created_at__extract_doy + , subq_14.listing__ds__day + , subq_14.listing__ds__week + , subq_14.listing__ds__month + , subq_14.listing__ds__quarter + , subq_14.listing__ds__year + , subq_14.listing__ds__extract_year + , subq_14.listing__ds__extract_quarter + , subq_14.listing__ds__extract_month + , subq_14.listing__ds__extract_day + , subq_14.listing__ds__extract_dow + , subq_14.listing__ds__extract_doy + , subq_14.listing__created_at__day + , subq_14.listing__created_at__week + , subq_14.listing__created_at__month + , subq_14.listing__created_at__quarter + , subq_14.listing__created_at__year + , subq_14.listing__created_at__extract_year + , subq_14.listing__created_at__extract_quarter + , subq_14.listing__created_at__extract_month + , subq_14.listing__created_at__extract_day + , subq_14.listing__created_at__extract_dow + , subq_14.listing__created_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.user + , subq_14.listing__user + , subq_14.country_latest + , subq_14.is_lux_latest + , subq_14.capacity_latest + , subq_14.listing__country_latest + , subq_14.listing__is_lux_latest + , subq_14.listing__capacity_latest + , subq_14.listings + , subq_14.largest_listing + , subq_14.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_5 - ) subq_6 - ) subq_7 - ) subq_8 - ) subq_9 -) subq_10 + , 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_14 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index 13f8ff2353..c293244ecc 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_15.bookings) AS DOUBLE) / CAST(NULLIF(MAX(subq_20.listings), 0) AS DOUBLE) AS bookings_per_listing + CAST(MAX(subq_24.bookings) AS DOUBLE) / CAST(NULLIF(MAX(subq_29.listings), 0) AS DOUBLE) AS bookings_per_listing FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -10,8 +10,8 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_24 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -20,5 +20,5 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_20 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_29 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_categorical__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_categorical__plan0.sql index 9b68bd0453..6c09f964b3 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_categorical__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_categorical__plan0.sql @@ -10,62 +10,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 GROUP BY subq_0.listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_categorical__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_categorical__plan0_optimized.sql index c1da0c0382..a8d1afa6a8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_categorical__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_categorical__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 GROUP BY country ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time__plan0.sql index ac6e043c67..4ac88db406 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY subq_0.booking__paid_at__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time__plan0_optimized.sql index 280b915894..e6a861c58f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__day',] SELECT DATE_TRUNC('day', paid_at) AS booking__paid_at__day - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', paid_at) ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time_quarter__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time_quarter__plan0.sql index ea8910605f..26bfd8c1d1 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time_quarter__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time_quarter__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY subq_0.booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time_quarter__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time_quarter__plan0_optimized.sql index f6d583edbe..5ff0fa4feb 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time_quarter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_min_max_only_time_quarter__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__quarter',] SELECT DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('quarter', paid_at) ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql index 95a99ec92d..874ac0743f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__user__home_state_latest - , subq_10.bookings + subq_23.metric_time__day + , subq_23.listing__user__home_state_latest + , subq_23.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest - , SUM(subq_9.bookings) AS bookings + subq_22.metric_time__day + , subq_22.listing__user__home_state_latest + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__home_state_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__user__home_state_latest - , subq_8.bookings + subq_21.metric_time__day + , subq_21.listing__user__home_state_latest + , subq_21.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.window_start__day AS listing__window_start__day - , subq_7.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_7.user__home_state_latest AS listing__user__home_state_latest - , subq_2.bookings AS bookings + subq_15.metric_time__day AS metric_time__day + , subq_20.window_start__day AS listing__window_start__day + , subq_20.window_end__day AS listing__window_end__day + , subq_15.listing AS listing + , subq_20.user__home_state_latest AS listing__user__home_state_latest + , subq_15.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_14.metric_time__day + , subq_14.listing + , subq_14.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.user + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.booking__user + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.bookers + , subq_13.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,142 +211,142 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_13 + ) subq_14 + ) subq_15 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_6.window_start__day - , subq_6.window_end__day - , subq_6.listing - , subq_6.user__home_state_latest + subq_19.window_start__day + , subq_19.window_end__day + , subq_19.listing + , subq_19.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_3.window_start__day AS window_start__day - , subq_3.window_start__week AS window_start__week - , subq_3.window_start__month AS window_start__month - , subq_3.window_start__quarter AS window_start__quarter - , subq_3.window_start__year AS window_start__year - , subq_3.window_start__extract_year AS window_start__extract_year - , subq_3.window_start__extract_quarter AS window_start__extract_quarter - , subq_3.window_start__extract_month AS window_start__extract_month - , subq_3.window_start__extract_day AS window_start__extract_day - , subq_3.window_start__extract_dow AS window_start__extract_dow - , subq_3.window_start__extract_doy AS window_start__extract_doy - , subq_3.window_end__day AS window_end__day - , subq_3.window_end__week AS window_end__week - , subq_3.window_end__month AS window_end__month - , subq_3.window_end__quarter AS window_end__quarter - , subq_3.window_end__year AS window_end__year - , subq_3.window_end__extract_year AS window_end__extract_year - , subq_3.window_end__extract_quarter AS window_end__extract_quarter - , subq_3.window_end__extract_month AS window_end__extract_month - , subq_3.window_end__extract_day AS window_end__extract_day - , subq_3.window_end__extract_dow AS window_end__extract_dow - , subq_3.window_end__extract_doy AS window_end__extract_doy - , subq_3.listing__window_start__day AS listing__window_start__day - , subq_3.listing__window_start__week AS listing__window_start__week - , subq_3.listing__window_start__month AS listing__window_start__month - , subq_3.listing__window_start__quarter AS listing__window_start__quarter - , subq_3.listing__window_start__year AS listing__window_start__year - , subq_3.listing__window_start__extract_year AS listing__window_start__extract_year - , subq_3.listing__window_start__extract_quarter AS listing__window_start__extract_quarter - , subq_3.listing__window_start__extract_month AS listing__window_start__extract_month - , subq_3.listing__window_start__extract_day AS listing__window_start__extract_day - , subq_3.listing__window_start__extract_dow AS listing__window_start__extract_dow - , subq_3.listing__window_start__extract_doy AS listing__window_start__extract_doy - , subq_3.listing__window_end__day AS listing__window_end__day - , subq_3.listing__window_end__week AS listing__window_end__week - , subq_3.listing__window_end__month AS listing__window_end__month - , subq_3.listing__window_end__quarter AS listing__window_end__quarter - , subq_3.listing__window_end__year AS listing__window_end__year - , subq_3.listing__window_end__extract_year AS listing__window_end__extract_year - , subq_3.listing__window_end__extract_quarter AS listing__window_end__extract_quarter - , subq_3.listing__window_end__extract_month AS listing__window_end__extract_month - , subq_3.listing__window_end__extract_day AS listing__window_end__extract_day - , subq_3.listing__window_end__extract_dow AS listing__window_end__extract_dow - , subq_3.listing__window_end__extract_doy AS listing__window_end__extract_doy - , subq_5.ds__day AS user__ds__day - , subq_5.ds__week AS user__ds__week - , subq_5.ds__month AS user__ds__month - , subq_5.ds__quarter AS user__ds__quarter - , subq_5.ds__year AS user__ds__year - , subq_5.ds__extract_year AS user__ds__extract_year - , subq_5.ds__extract_quarter AS user__ds__extract_quarter - , subq_5.ds__extract_month AS user__ds__extract_month - , subq_5.ds__extract_day AS user__ds__extract_day - , subq_5.ds__extract_dow AS user__ds__extract_dow - , subq_5.ds__extract_doy AS user__ds__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country AS country - , subq_3.is_lux AS is_lux - , subq_3.capacity AS capacity - , subq_3.listing__country AS listing__country - , subq_3.listing__is_lux AS listing__is_lux - , subq_3.listing__capacity AS listing__capacity - , subq_5.home_state_latest AS user__home_state_latest + subq_16.window_start__day AS window_start__day + , subq_16.window_start__week AS window_start__week + , subq_16.window_start__month AS window_start__month + , subq_16.window_start__quarter AS window_start__quarter + , subq_16.window_start__year AS window_start__year + , subq_16.window_start__extract_year AS window_start__extract_year + , subq_16.window_start__extract_quarter AS window_start__extract_quarter + , subq_16.window_start__extract_month AS window_start__extract_month + , subq_16.window_start__extract_day AS window_start__extract_day + , subq_16.window_start__extract_dow AS window_start__extract_dow + , subq_16.window_start__extract_doy AS window_start__extract_doy + , subq_16.window_end__day AS window_end__day + , subq_16.window_end__week AS window_end__week + , subq_16.window_end__month AS window_end__month + , subq_16.window_end__quarter AS window_end__quarter + , subq_16.window_end__year AS window_end__year + , subq_16.window_end__extract_year AS window_end__extract_year + , subq_16.window_end__extract_quarter AS window_end__extract_quarter + , subq_16.window_end__extract_month AS window_end__extract_month + , subq_16.window_end__extract_day AS window_end__extract_day + , subq_16.window_end__extract_dow AS window_end__extract_dow + , subq_16.window_end__extract_doy AS window_end__extract_doy + , subq_16.listing__window_start__day AS listing__window_start__day + , subq_16.listing__window_start__week AS listing__window_start__week + , subq_16.listing__window_start__month AS listing__window_start__month + , subq_16.listing__window_start__quarter AS listing__window_start__quarter + , subq_16.listing__window_start__year AS listing__window_start__year + , subq_16.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_16.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_16.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_16.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_16.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_16.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_16.listing__window_end__day AS listing__window_end__day + , subq_16.listing__window_end__week AS listing__window_end__week + , subq_16.listing__window_end__month AS listing__window_end__month + , subq_16.listing__window_end__quarter AS listing__window_end__quarter + , subq_16.listing__window_end__year AS listing__window_end__year + , subq_16.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_16.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_16.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_16.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_16.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_16.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_18.ds__day AS user__ds__day + , subq_18.ds__week AS user__ds__week + , subq_18.ds__month AS user__ds__month + , subq_18.ds__quarter AS user__ds__quarter + , subq_18.ds__year AS user__ds__year + , subq_18.ds__extract_year AS user__ds__extract_year + , subq_18.ds__extract_quarter AS user__ds__extract_quarter + , subq_18.ds__extract_month AS user__ds__extract_month + , subq_18.ds__extract_day AS user__ds__extract_day + , subq_18.ds__extract_dow AS user__ds__extract_dow + , subq_18.ds__extract_doy AS user__ds__extract_doy + , subq_16.listing AS listing + , subq_16.user AS user + , subq_16.listing__user AS listing__user + , subq_16.country AS country + , subq_16.is_lux AS is_lux + , subq_16.capacity AS capacity + , subq_16.listing__country AS listing__country + , subq_16.listing__is_lux AS listing__is_lux + , subq_16.listing__capacity AS listing__capacity + , subq_18.home_state_latest AS user__home_state_latest FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26002.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26002.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26002.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26002.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26000.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26000.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26000.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_src_26000.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_16 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,83 +376,83 @@ FROM ( -- 'user', -- ] SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.user__ds__day - , subq_4.user__ds__week - , subq_4.user__ds__month - , subq_4.user__ds__quarter - , subq_4.user__ds__year - , subq_4.user__ds__extract_year - , subq_4.user__ds__extract_quarter - , subq_4.user__ds__extract_month - , subq_4.user__ds__extract_day - , subq_4.user__ds__extract_dow - , subq_4.user__ds__extract_doy - , subq_4.user - , subq_4.home_state_latest - , subq_4.user__home_state_latest + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.user__ds__day + , subq_17.user__ds__week + , subq_17.user__ds__month + , subq_17.user__ds__quarter + , subq_17.user__ds__year + , subq_17.user__ds__extract_year + , subq_17.user__ds__extract_quarter + , subq_17.user__ds__extract_month + , subq_17.user__ds__extract_day + , subq_17.user__ds__extract_dow + , subq_17.user__ds__extract_doy + , subq_17.user + , subq_17.home_state_latest + , subq_17.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_26006.ds) AS ds__day - , DATE_TRUNC('week', users_latest_src_26006.ds) AS ds__week - , DATE_TRUNC('month', users_latest_src_26006.ds) AS ds__month - , DATE_TRUNC('quarter', users_latest_src_26006.ds) AS ds__quarter - , DATE_TRUNC('year', users_latest_src_26006.ds) AS ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_26006.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_latest_src_26006.ds) AS ds__extract_doy - , users_latest_src_26006.home_state_latest - , DATE_TRUNC('day', users_latest_src_26006.ds) AS user__ds__day - , DATE_TRUNC('week', users_latest_src_26006.ds) AS user__ds__week - , DATE_TRUNC('month', users_latest_src_26006.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_latest_src_26006.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_latest_src_26006.ds) AS user__ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS user__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_26006.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_latest_src_26006.ds) AS user__ds__extract_doy - , users_latest_src_26006.home_state_latest AS user__home_state_latest - , users_latest_src_26006.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_26006 - ) subq_4 - ) subq_5 + DATE_TRUNC('day', users_latest_src_26000.ds) AS ds__day + , DATE_TRUNC('week', users_latest_src_26000.ds) AS ds__week + , DATE_TRUNC('month', users_latest_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', users_latest_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', users_latest_src_26000.ds) AS ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_latest_src_26000.ds) AS ds__extract_doy + , users_latest_src_26000.home_state_latest + , DATE_TRUNC('day', users_latest_src_26000.ds) AS user__ds__day + , DATE_TRUNC('week', users_latest_src_26000.ds) AS user__ds__week + , DATE_TRUNC('month', users_latest_src_26000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_latest_src_26000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_latest_src_26000.ds) AS user__ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS user__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_26000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_latest_src_26000.ds) AS user__ds__extract_doy + , users_latest_src_26000.home_state_latest AS user__home_state_latest + , users_latest_src_26000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_26000 + ) subq_17 + ) subq_18 ON - subq_3.user = subq_5.user - ) subq_6 - ) subq_7 + subq_16.user = subq_18.user + ) subq_19 + ) subq_20 ON ( - subq_2.listing = subq_7.listing + subq_15.listing = subq_20.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.window_start__day + subq_15.metric_time__day >= subq_20.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.window_end__day + subq_15.metric_time__day < subq_20.window_end__day ) OR ( - subq_7.window_end__day IS NULL + subq_20.window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_21 + ) subq_22 GROUP BY - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest -) subq_10 + subq_22.metric_time__day + , subq_22.listing__user__home_state_latest +) subq_23 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 1d7e6c24a7..f38afda4f7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.user__home_state_latest AS listing__user__home_state_latest - , SUM(subq_13.bookings) AS bookings + subq_26.metric_time__day AS metric_time__day + , subq_31.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_26.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,35 +15,35 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_26 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - listings_src_26002.active_from AS window_start__day - , listings_src_26002.active_to AS window_end__day - , listings_src_26002.listing_id AS listing - , users_latest_src_26006.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings listings_src_26002 + listings_src_26000.active_from AS window_start__day + , listings_src_26000.active_to AS window_end__day + , listings_src_26000.listing_id AS listing + , users_latest_src_26000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings listings_src_26000 LEFT OUTER JOIN - ***************************.dim_users_latest users_latest_src_26006 + ***************************.dim_users_latest users_latest_src_26000 ON - listings_src_26002.user_id = users_latest_src_26006.user_id -) subq_18 + listings_src_26000.user_id = users_latest_src_26000.user_id +) subq_31 ON ( - subq_13.listing = subq_18.listing + subq_26.listing = subq_31.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_26.metric_time__day >= subq_31.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_26.metric_time__day < subq_31.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_31.window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.user__home_state_latest + subq_26.metric_time__day + , subq_31.user__home_state_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql index 013554e39e..b81180358d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__lux_listing__is_confirmed_lux - , subq_10.bookings + subq_15.metric_time__day + , subq_15.listing__lux_listing__is_confirmed_lux + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux - , SUM(subq_9.bookings) AS bookings + subq_14.metric_time__day + , subq_14.listing__lux_listing__is_confirmed_lux + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__lux_listing__is_confirmed_lux', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__lux_listing__is_confirmed_lux - , subq_8.bookings + subq_13.metric_time__day + , subq_13.listing__lux_listing__is_confirmed_lux + , subq_13.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.lux_listing__window_start__day AS listing__lux_listing__window_start__day - , subq_7.lux_listing__window_end__day AS listing__lux_listing__window_end__day - , subq_2.listing AS listing - , subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , subq_2.bookings AS bookings + subq_7.metric_time__day AS metric_time__day + , subq_12.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_12.lux_listing__window_end__day AS listing__lux_listing__window_end__day + , subq_7.listing AS listing + , subq_12.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_7.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_6.metric_time__day + , subq_6.listing + , subq_6.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.ds__day AS metric_time__day + , subq_5.ds__week AS metric_time__week + , subq_5.ds__month AS metric_time__month + , subq_5.ds__quarter AS metric_time__quarter + , subq_5.ds__year AS metric_time__year + , subq_5.ds__extract_year AS metric_time__extract_year + , subq_5.ds__extract_quarter AS metric_time__extract_quarter + , subq_5.ds__extract_month AS metric_time__extract_month + , subq_5.ds__extract_day AS metric_time__extract_day + , subq_5.ds__extract_dow AS metric_time__extract_dow + , subq_5.ds__extract_doy AS metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.user + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.booking__user + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.bookings + , subq_5.instant_bookings + , subq_5.booking_value + , subq_5.bookers + , subq_5.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,53 +211,53 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_5 + ) subq_6 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - subq_6.lux_listing__window_start__day - , subq_6.lux_listing__window_end__day - , subq_6.listing - , subq_6.lux_listing__is_confirmed_lux + subq_11.lux_listing__window_start__day + , subq_11.lux_listing__window_end__day + , subq_11.listing + , subq_11.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_5.window_start__day AS lux_listing__window_start__day - , subq_5.window_start__week AS lux_listing__window_start__week - , subq_5.window_start__month AS lux_listing__window_start__month - , subq_5.window_start__quarter AS lux_listing__window_start__quarter - , subq_5.window_start__year AS lux_listing__window_start__year - , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_5.window_end__day AS lux_listing__window_end__day - , subq_5.window_end__week AS lux_listing__window_end__week - , subq_5.window_end__month AS lux_listing__window_end__month - , subq_5.window_end__quarter AS lux_listing__window_end__quarter - , subq_5.window_end__year AS lux_listing__window_end__year - , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_3.listing AS listing - , subq_3.lux_listing AS lux_listing - , subq_3.listing__lux_listing AS listing__lux_listing - , subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux + subq_10.window_start__day AS lux_listing__window_start__day + , subq_10.window_start__week AS lux_listing__window_start__week + , subq_10.window_start__month AS lux_listing__window_start__month + , subq_10.window_start__quarter AS lux_listing__window_start__quarter + , subq_10.window_start__year AS lux_listing__window_start__year + , subq_10.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_10.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_10.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_10.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_10.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_10.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_10.window_end__day AS lux_listing__window_end__day + , subq_10.window_end__week AS lux_listing__window_end__week + , subq_10.window_end__month AS lux_listing__window_end__month + , subq_10.window_end__quarter AS lux_listing__window_end__quarter + , subq_10.window_end__year AS lux_listing__window_end__year + , subq_10.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_10.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_10.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_10.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_10.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_10.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_8.listing AS listing + , subq_8.lux_listing AS lux_listing + , subq_8.listing__lux_listing AS listing__lux_listing + , subq_10.is_confirmed_lux AS lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT - lux_listing_mapping_src_26003.listing_id AS listing - , lux_listing_mapping_src_26003.lux_listing_id AS lux_listing - , lux_listing_mapping_src_26003.lux_listing_id AS listing__lux_listing - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 - ) subq_3 + lux_listing_mapping_src_26000.listing_id AS listing + , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing + , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 + ) subq_8 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,127 +309,127 @@ FROM ( -- 'lux_listing', -- ] SELECT - subq_4.window_start__day - , subq_4.window_start__week - , subq_4.window_start__month - , subq_4.window_start__quarter - , subq_4.window_start__year - , subq_4.window_start__extract_year - , subq_4.window_start__extract_quarter - , subq_4.window_start__extract_month - , subq_4.window_start__extract_day - , subq_4.window_start__extract_dow - , subq_4.window_start__extract_doy - , subq_4.window_end__day - , subq_4.window_end__week - , subq_4.window_end__month - , subq_4.window_end__quarter - , subq_4.window_end__year - , subq_4.window_end__extract_year - , subq_4.window_end__extract_quarter - , subq_4.window_end__extract_month - , subq_4.window_end__extract_day - , subq_4.window_end__extract_dow - , subq_4.window_end__extract_doy - , subq_4.lux_listing__window_start__day - , subq_4.lux_listing__window_start__week - , subq_4.lux_listing__window_start__month - , subq_4.lux_listing__window_start__quarter - , subq_4.lux_listing__window_start__year - , subq_4.lux_listing__window_start__extract_year - , subq_4.lux_listing__window_start__extract_quarter - , subq_4.lux_listing__window_start__extract_month - , subq_4.lux_listing__window_start__extract_day - , subq_4.lux_listing__window_start__extract_dow - , subq_4.lux_listing__window_start__extract_doy - , subq_4.lux_listing__window_end__day - , subq_4.lux_listing__window_end__week - , subq_4.lux_listing__window_end__month - , subq_4.lux_listing__window_end__quarter - , subq_4.lux_listing__window_end__year - , subq_4.lux_listing__window_end__extract_year - , subq_4.lux_listing__window_end__extract_quarter - , subq_4.lux_listing__window_end__extract_month - , subq_4.lux_listing__window_end__extract_day - , subq_4.lux_listing__window_end__extract_dow - , subq_4.lux_listing__window_end__extract_doy - , subq_4.lux_listing - , subq_4.is_confirmed_lux - , subq_4.lux_listing__is_confirmed_lux + subq_9.window_start__day + , subq_9.window_start__week + , subq_9.window_start__month + , subq_9.window_start__quarter + , subq_9.window_start__year + , subq_9.window_start__extract_year + , subq_9.window_start__extract_quarter + , subq_9.window_start__extract_month + , subq_9.window_start__extract_day + , subq_9.window_start__extract_dow + , subq_9.window_start__extract_doy + , subq_9.window_end__day + , subq_9.window_end__week + , subq_9.window_end__month + , subq_9.window_end__quarter + , subq_9.window_end__year + , subq_9.window_end__extract_year + , subq_9.window_end__extract_quarter + , subq_9.window_end__extract_month + , subq_9.window_end__extract_day + , subq_9.window_end__extract_dow + , subq_9.window_end__extract_doy + , subq_9.lux_listing__window_start__day + , subq_9.lux_listing__window_start__week + , subq_9.lux_listing__window_start__month + , subq_9.lux_listing__window_start__quarter + , subq_9.lux_listing__window_start__year + , subq_9.lux_listing__window_start__extract_year + , subq_9.lux_listing__window_start__extract_quarter + , subq_9.lux_listing__window_start__extract_month + , subq_9.lux_listing__window_start__extract_day + , subq_9.lux_listing__window_start__extract_dow + , subq_9.lux_listing__window_start__extract_doy + , subq_9.lux_listing__window_end__day + , subq_9.lux_listing__window_end__week + , subq_9.lux_listing__window_end__month + , subq_9.lux_listing__window_end__quarter + , subq_9.lux_listing__window_end__year + , subq_9.lux_listing__window_end__extract_year + , subq_9.lux_listing__window_end__extract_quarter + , subq_9.lux_listing__window_end__extract_month + , subq_9.lux_listing__window_end__extract_day + , subq_9.lux_listing__window_end__extract_dow + , subq_9.lux_listing__window_end__extract_doy + , subq_9.lux_listing + , subq_9.is_confirmed_lux + , subq_9.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT - lux_listings_src_26004.valid_from AS window_start__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_from) AS window_start__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_from) AS window_start__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_from) AS window_start__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_from) AS window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS window_start__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_26004.valid_from) AS window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_from) AS window_start__extract_doy - , lux_listings_src_26004.valid_to AS window_end__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_to) AS window_end__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_to) AS window_end__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_to) AS window_end__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_to) AS window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS window_end__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_26004.valid_to) AS window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_to) AS window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux - , lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_from) AS lux_listing__window_start__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_from) AS lux_listing__window_start__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_from) AS lux_listing__window_start__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_from) AS lux_listing__window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_doy - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_to) AS lux_listing__window_end__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_to) AS lux_listing__window_end__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_to) AS lux_listing__window_end__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_to) AS lux_listing__window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - , lux_listings_src_26004.lux_listing_id AS lux_listing - FROM ***************************.dim_lux_listings lux_listings_src_26004 - ) subq_4 - ) subq_5 + lux_listings_src_26000.valid_from AS window_start__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_from) AS window_start__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_from) AS window_start__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_from) AS window_start__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_from) AS window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS window_start__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_26000.valid_from) AS window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_from) AS window_start__extract_doy + , lux_listings_src_26000.valid_to AS window_end__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_to) AS window_end__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_to) AS window_end__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_to) AS window_end__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_to) AS window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS window_end__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_26000.valid_to) AS window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_to) AS window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux + , lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_from) AS lux_listing__window_start__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_from) AS lux_listing__window_start__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_from) AS lux_listing__window_start__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_from) AS lux_listing__window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_doy + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_to) AS lux_listing__window_end__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_to) AS lux_listing__window_end__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_to) AS lux_listing__window_end__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_to) AS lux_listing__window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + , lux_listings_src_26000.lux_listing_id AS lux_listing + FROM ***************************.dim_lux_listings lux_listings_src_26000 + ) subq_9 + ) subq_10 ON - subq_3.lux_listing = subq_5.lux_listing - ) subq_6 - ) subq_7 + subq_8.lux_listing = subq_10.lux_listing + ) subq_11 + ) subq_12 ON ( - subq_2.listing = subq_7.listing + subq_7.listing = subq_12.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.lux_listing__window_start__day + subq_7.metric_time__day >= subq_12.lux_listing__window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.lux_listing__window_end__day + subq_7.metric_time__day < subq_12.lux_listing__window_end__day ) OR ( - subq_7.lux_listing__window_end__day IS NULL + subq_12.lux_listing__window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_13 + ) subq_14 GROUP BY - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux -) subq_10 + subq_14.metric_time__day + , subq_14.listing__lux_listing__is_confirmed_lux +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql index 0ef5f08ffa..eb9b15d13c 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , SUM(subq_13.bookings) AS bookings + subq_18.metric_time__day AS metric_time__day + , subq_23.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_18.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,35 +15,35 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_18 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , lux_listing_mapping_src_26003.listing_id AS listing - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 + lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , lux_listing_mapping_src_26000.listing_id AS listing + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 LEFT OUTER JOIN - ***************************.dim_lux_listings lux_listings_src_26004 + ***************************.dim_lux_listings lux_listings_src_26000 ON - lux_listing_mapping_src_26003.lux_listing_id = lux_listings_src_26004.lux_listing_id -) subq_18 + lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id +) subq_23 ON ( - subq_13.listing = subq_18.listing + subq_18.listing = subq_23.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.lux_listing__window_start__day + subq_18.metric_time__day >= subq_23.lux_listing__window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.lux_listing__window_end__day + subq_18.metric_time__day < subq_23.lux_listing__window_end__day ) OR ( - subq_18.lux_listing__window_end__day IS NULL + subq_23.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.lux_listing__is_confirmed_lux + subq_18.metric_time__day + , subq_23.lux_listing__is_confirmed_lux diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql index 761fdeec7d..d05bcc7de3 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql @@ -1,93 +1,93 @@ -- Compute Metrics via Expressions SELECT - subq_10.account_id__customer_id__customer_name - , subq_10.txn_count + subq_14.account_id__customer_id__customer_name + , subq_14.txn_count FROM ( -- Aggregate Measures SELECT - subq_9.account_id__customer_id__customer_name - , SUM(subq_9.txn_count) AS txn_count + subq_13.account_id__customer_id__customer_name + , SUM(subq_13.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_8.account_id__customer_id__customer_name - , subq_8.txn_count + subq_12.account_id__customer_id__customer_name + , subq_12.txn_count FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_2.account_id AS account_id - , subq_7.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_2.txn_count AS txn_count + subq_6.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_6.account_id AS account_id + , subq_11.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_6.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_1.ds_partitioned__day - , subq_1.account_id - , subq_1.txn_count + subq_5.ds_partitioned__day + , subq_5.account_id + , subq_5.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.account_id__ds_partitioned__day - , subq_0.account_id__ds_partitioned__week - , subq_0.account_id__ds_partitioned__month - , subq_0.account_id__ds_partitioned__quarter - , subq_0.account_id__ds_partitioned__year - , subq_0.account_id__ds_partitioned__extract_year - , subq_0.account_id__ds_partitioned__extract_quarter - , subq_0.account_id__ds_partitioned__extract_month - , subq_0.account_id__ds_partitioned__extract_day - , subq_0.account_id__ds_partitioned__extract_dow - , subq_0.account_id__ds_partitioned__extract_doy - , subq_0.account_id__ds__day - , subq_0.account_id__ds__week - , subq_0.account_id__ds__month - , subq_0.account_id__ds__quarter - , subq_0.account_id__ds__year - , subq_0.account_id__ds__extract_year - , subq_0.account_id__ds__extract_quarter - , subq_0.account_id__ds__extract_month - , subq_0.account_id__ds__extract_day - , subq_0.account_id__ds__extract_dow - , subq_0.account_id__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.account_id - , subq_0.account_month - , subq_0.account_id__account_month - , subq_0.txn_count + subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.account_id__ds_partitioned__day + , subq_4.account_id__ds_partitioned__week + , subq_4.account_id__ds_partitioned__month + , subq_4.account_id__ds_partitioned__quarter + , subq_4.account_id__ds_partitioned__year + , subq_4.account_id__ds_partitioned__extract_year + , subq_4.account_id__ds_partitioned__extract_quarter + , subq_4.account_id__ds_partitioned__extract_month + , subq_4.account_id__ds_partitioned__extract_day + , subq_4.account_id__ds_partitioned__extract_dow + , subq_4.account_id__ds_partitioned__extract_doy + , subq_4.account_id__ds__day + , subq_4.account_id__ds__week + , subq_4.account_id__ds__month + , subq_4.account_id__ds__quarter + , subq_4.account_id__ds__year + , subq_4.account_id__ds__extract_year + , subq_4.account_id__ds__extract_quarter + , subq_4.account_id__ds__extract_month + , subq_4.account_id__ds__extract_day + , subq_4.account_id__ds__extract_dow + , subq_4.account_id__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.account_id + , subq_4.account_month + , subq_4.account_id__account_month + , subq_4.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -140,118 +140,118 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_4 + ) subq_5 + ) subq_6 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_6.ds_partitioned__day - , subq_6.account_id - , subq_6.customer_id__customer_name + subq_10.ds_partitioned__day + , subq_10.account_id + , subq_10.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_3.ds_partitioned__day AS ds_partitioned__day - , subq_3.ds_partitioned__week AS ds_partitioned__week - , subq_3.ds_partitioned__month AS ds_partitioned__month - , subq_3.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_3.ds_partitioned__year AS ds_partitioned__year - , subq_3.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_3.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_3.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_3.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_3.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_3.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_3.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_3.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_3.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_3.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_3.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_3.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_3.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_5.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_5.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_5.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_5.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_5.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_5.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_3.account_id AS account_id - , subq_3.customer_id AS customer_id - , subq_3.account_id__customer_id AS account_id__customer_id - , subq_3.bridge_account__account_id AS bridge_account__account_id - , subq_3.bridge_account__customer_id AS bridge_account__customer_id - , subq_3.extra_dim AS extra_dim - , subq_3.account_id__extra_dim AS account_id__extra_dim - , subq_3.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_5.customer_name AS customer_id__customer_name - , subq_5.customer_atomic_weight AS customer_id__customer_atomic_weight + subq_7.ds_partitioned__day AS ds_partitioned__day + , subq_7.ds_partitioned__week AS ds_partitioned__week + , subq_7.ds_partitioned__month AS ds_partitioned__month + , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_7.ds_partitioned__year AS ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_9.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_9.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_9.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_9.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_9.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_9.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_7.account_id AS account_id + , subq_7.customer_id AS customer_id + , subq_7.account_id__customer_id AS account_id__customer_id + , subq_7.bridge_account__account_id AS bridge_account__account_id + , subq_7.bridge_account__customer_id AS bridge_account__customer_id + , subq_7.extra_dim AS extra_dim + , subq_7.account_id__extra_dim AS account_id__extra_dim + , subq_7.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_9.customer_name AS customer_id__customer_name + , subq_9.customer_atomic_weight AS customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT - bridge_table_src_22001.extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS account_id__extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS bridge_account__extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy - , bridge_table_src_22001.account_id - , bridge_table_src_22001.customer_id - , bridge_table_src_22001.customer_id AS account_id__customer_id - , bridge_table_src_22001.account_id AS bridge_account__account_id - , bridge_table_src_22001.customer_id AS bridge_account__customer_id - FROM ***************************.bridge_table bridge_table_src_22001 - ) subq_3 + bridge_table_src_22000.extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS account_id__extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS bridge_account__extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy + , bridge_table_src_22000.account_id + , bridge_table_src_22000.customer_id + , bridge_table_src_22000.customer_id AS account_id__customer_id + , bridge_table_src_22000.account_id AS bridge_account__account_id + , bridge_table_src_22000.customer_id AS bridge_account__customer_id + FROM ***************************.bridge_table bridge_table_src_22000 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -283,82 +283,82 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.customer_id__ds_partitioned__day - , subq_4.customer_id__ds_partitioned__week - , subq_4.customer_id__ds_partitioned__month - , subq_4.customer_id__ds_partitioned__quarter - , subq_4.customer_id__ds_partitioned__year - , subq_4.customer_id__ds_partitioned__extract_year - , subq_4.customer_id__ds_partitioned__extract_quarter - , subq_4.customer_id__ds_partitioned__extract_month - , subq_4.customer_id__ds_partitioned__extract_day - , subq_4.customer_id__ds_partitioned__extract_dow - , subq_4.customer_id__ds_partitioned__extract_doy - , subq_4.customer_id - , subq_4.customer_name - , subq_4.customer_atomic_weight - , subq_4.customer_id__customer_name - , subq_4.customer_id__customer_atomic_weight + subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.customer_id__ds_partitioned__day + , subq_8.customer_id__ds_partitioned__week + , subq_8.customer_id__ds_partitioned__month + , subq_8.customer_id__ds_partitioned__quarter + , subq_8.customer_id__ds_partitioned__year + , subq_8.customer_id__ds_partitioned__extract_year + , subq_8.customer_id__ds_partitioned__extract_quarter + , subq_8.customer_id__ds_partitioned__extract_month + , subq_8.customer_id__ds_partitioned__extract_day + , subq_8.customer_id__ds_partitioned__extract_dow + , subq_8.customer_id__ds_partitioned__extract_doy + , subq_8.customer_id + , subq_8.customer_name + , subq_8.customer_atomic_weight + , subq_8.customer_id__customer_name + , subq_8.customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT - customer_table_src_22003.customer_name - , customer_table_src_22003.customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_22003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_22003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_22003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_22003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_doy - , customer_table_src_22003.customer_name AS customer_id__customer_name - , customer_table_src_22003.customer_atomic_weight AS customer_id__customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_doy - , customer_table_src_22003.customer_id - FROM ***************************.customer_table customer_table_src_22003 - ) subq_4 - ) subq_5 + customer_table_src_22000.customer_name + , customer_table_src_22000.customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , customer_table_src_22000.customer_name AS customer_id__customer_name + , customer_table_src_22000.customer_atomic_weight AS customer_id__customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy + , customer_table_src_22000.customer_id + FROM ***************************.customer_table customer_table_src_22000 + ) subq_8 + ) subq_9 ON ( - subq_3.customer_id = subq_5.customer_id + subq_7.customer_id = subq_9.customer_id ) AND ( - subq_3.ds_partitioned__day = subq_5.ds_partitioned__day + subq_7.ds_partitioned__day = subq_9.ds_partitioned__day ) - ) subq_6 - ) subq_7 + ) subq_10 + ) subq_11 ON ( - subq_2.account_id = subq_7.account_id + subq_6.account_id = subq_11.account_id ) AND ( - subq_2.ds_partitioned__day = subq_7.ds_partitioned__day + subq_6.ds_partitioned__day = subq_11.ds_partitioned__day ) - ) subq_8 - ) subq_9 + ) subq_12 + ) subq_13 GROUP BY - subq_9.account_id__customer_id__customer_name -) subq_10 + subq_13.account_id__customer_id__customer_name +) subq_14 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql index 7802d2f867..13473156ca 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql @@ -3,31 +3,31 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_18.customer_id__customer_name AS account_id__customer_id__customer_name + subq_22.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__day - , bridge_table_src_22001.account_id AS account_id - , customer_table_src_22003.customer_name AS customer_id__customer_name - FROM ***************************.bridge_table bridge_table_src_22001 + DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__day + , bridge_table_src_22000.account_id AS account_id + , customer_table_src_22000.customer_name AS customer_id__customer_name + FROM ***************************.bridge_table bridge_table_src_22000 LEFT OUTER JOIN - ***************************.customer_table customer_table_src_22003 + ***************************.customer_table customer_table_src_22000 ON ( - bridge_table_src_22001.customer_id = customer_table_src_22003.customer_id + bridge_table_src_22000.customer_id = customer_table_src_22000.customer_id ) AND ( - DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) + DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_18 +) subq_22 ON ( - account_month_txns_src_22000.account_id = subq_18.account_id + account_month_txns_src_22000.account_id = subq_22.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day ) GROUP BY - subq_18.customer_id__customer_name + subq_22.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql index e00740355f..18bc192cee 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql @@ -1,536 +1,536 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_5.bookings) AS bookings - , MAX(subq_11.listings) AS listings + MAX(subq_18.bookings) AS bookings + , MAX(subq_24.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_4.bookings + subq_17.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_3.bookings) AS bookings + SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_2.bookings + subq_15.bookings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.ds_partitioned__day - , subq_1.ds_partitioned__week - , subq_1.ds_partitioned__month - , subq_1.ds_partitioned__quarter - , subq_1.ds_partitioned__year - , subq_1.ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy - , subq_1.paid_at__day - , subq_1.paid_at__week - , subq_1.paid_at__month - , subq_1.paid_at__quarter - , subq_1.paid_at__year - , subq_1.paid_at__extract_year - , subq_1.paid_at__extract_quarter - , subq_1.paid_at__extract_month - , subq_1.paid_at__extract_day - , subq_1.paid_at__extract_dow - , subq_1.paid_at__extract_doy - , subq_1.booking__ds__day - , subq_1.booking__ds__week - , subq_1.booking__ds__month - , subq_1.booking__ds__quarter - , subq_1.booking__ds__year - , subq_1.booking__ds__extract_year - , subq_1.booking__ds__extract_quarter - , subq_1.booking__ds__extract_month - , subq_1.booking__ds__extract_day - , subq_1.booking__ds__extract_dow - , subq_1.booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day - , subq_1.booking__paid_at__week - , subq_1.booking__paid_at__month - , subq_1.booking__paid_at__quarter - , subq_1.booking__paid_at__year - , subq_1.booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.listing - , subq_1.guest - , subq_1.host - , subq_1.booking__listing - , subq_1.booking__guest - , subq_1.booking__host - , subq_1.is_instant - , subq_1.booking__is_instant - , subq_1.bookings - , subq_1.instant_bookings - , subq_1.booking_value - , subq_1.max_booking_value - , subq_1.min_booking_value - , subq_1.bookers - , subq_1.average_booking_value - , subq_1.referred_bookings - , subq_1.median_booking_value - , subq_1.booking_value_p99 - , subq_1.discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 + subq_14.ds__day + , subq_14.ds__week + , subq_14.ds__month + , subq_14.ds__quarter + , subq_14.ds__year + , subq_14.ds__extract_year + , subq_14.ds__extract_quarter + , subq_14.ds__extract_month + , subq_14.ds__extract_day + , subq_14.ds__extract_dow + , subq_14.ds__extract_doy + , subq_14.ds_partitioned__day + , subq_14.ds_partitioned__week + , subq_14.ds_partitioned__month + , subq_14.ds_partitioned__quarter + , subq_14.ds_partitioned__year + , subq_14.ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy + , subq_14.paid_at__day + , subq_14.paid_at__week + , subq_14.paid_at__month + , subq_14.paid_at__quarter + , subq_14.paid_at__year + , subq_14.paid_at__extract_year + , subq_14.paid_at__extract_quarter + , subq_14.paid_at__extract_month + , subq_14.paid_at__extract_day + , subq_14.paid_at__extract_dow + , subq_14.paid_at__extract_doy + , subq_14.booking__ds__day + , subq_14.booking__ds__week + , subq_14.booking__ds__month + , subq_14.booking__ds__quarter + , subq_14.booking__ds__year + , subq_14.booking__ds__extract_year + , subq_14.booking__ds__extract_quarter + , subq_14.booking__ds__extract_month + , subq_14.booking__ds__extract_day + , subq_14.booking__ds__extract_dow + , subq_14.booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day + , subq_14.booking__paid_at__week + , subq_14.booking__paid_at__month + , subq_14.booking__paid_at__quarter + , subq_14.booking__paid_at__year + , subq_14.booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy + , subq_14.metric_time__day + , subq_14.metric_time__week + , subq_14.metric_time__month + , subq_14.metric_time__quarter + , subq_14.metric_time__year + , subq_14.metric_time__extract_year + , subq_14.metric_time__extract_quarter + , subq_14.metric_time__extract_month + , subq_14.metric_time__extract_day + , subq_14.metric_time__extract_dow + , subq_14.metric_time__extract_doy + , subq_14.listing + , subq_14.guest + , subq_14.host + , subq_14.booking__listing + , subq_14.booking__guest + , subq_14.booking__host + , subq_14.is_instant + , subq_14.booking__is_instant + , subq_14.bookings + , subq_14.instant_bookings + , subq_14.booking_value + , subq_14.max_booking_value + , subq_14.min_booking_value + , subq_14.bookers + , subq_14.average_booking_value + , subq_14.referred_bookings + , subq_14.median_booking_value + , subq_14.booking_value_p99 + , subq_14.discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_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 + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.max_booking_value + , subq_13.min_booking_value + , subq_13.bookers + , subq_13.average_booking_value + , subq_13.referred_bookings + , subq_13.median_booking_value + , subq_13.booking_value_p99 + , subq_13.discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_2 - ) subq_3 - ) subq_4 -) subq_5 + , 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_13 + ) subq_14 + WHERE subq_14.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_15 + ) subq_16 + ) subq_17 +) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.listings + subq_23.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_9.listings) AS listings + SUM(subq_22.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_8.listings + subq_21.listings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] 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.created_at__day - , subq_7.created_at__week - , subq_7.created_at__month - , subq_7.created_at__quarter - , subq_7.created_at__year - , subq_7.created_at__extract_year - , subq_7.created_at__extract_quarter - , subq_7.created_at__extract_month - , subq_7.created_at__extract_day - , subq_7.created_at__extract_dow - , subq_7.created_at__extract_doy - , subq_7.listing__ds__day - , subq_7.listing__ds__week - , subq_7.listing__ds__month - , subq_7.listing__ds__quarter - , subq_7.listing__ds__year - , subq_7.listing__ds__extract_year - , subq_7.listing__ds__extract_quarter - , subq_7.listing__ds__extract_month - , subq_7.listing__ds__extract_day - , subq_7.listing__ds__extract_dow - , subq_7.listing__ds__extract_doy - , subq_7.listing__created_at__day - , subq_7.listing__created_at__week - , subq_7.listing__created_at__month - , subq_7.listing__created_at__quarter - , subq_7.listing__created_at__year - , subq_7.listing__created_at__extract_year - , subq_7.listing__created_at__extract_quarter - , subq_7.listing__created_at__extract_month - , subq_7.listing__created_at__extract_day - , subq_7.listing__created_at__extract_dow - , subq_7.listing__created_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.user - , subq_7.listing__user - , subq_7.country_latest - , subq_7.is_lux_latest - , subq_7.capacity_latest - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.listings - , subq_7.largest_listing - , subq_7.smallest_listing + 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.created_at__day + , subq_20.created_at__week + , subq_20.created_at__month + , subq_20.created_at__quarter + , subq_20.created_at__year + , subq_20.created_at__extract_year + , subq_20.created_at__extract_quarter + , subq_20.created_at__extract_month + , subq_20.created_at__extract_day + , subq_20.created_at__extract_dow + , subq_20.created_at__extract_doy + , subq_20.listing__ds__day + , subq_20.listing__ds__week + , subq_20.listing__ds__month + , subq_20.listing__ds__quarter + , subq_20.listing__ds__year + , subq_20.listing__ds__extract_year + , subq_20.listing__ds__extract_quarter + , subq_20.listing__ds__extract_month + , subq_20.listing__ds__extract_day + , subq_20.listing__ds__extract_dow + , subq_20.listing__ds__extract_doy + , subq_20.listing__created_at__day + , subq_20.listing__created_at__week + , subq_20.listing__created_at__month + , subq_20.listing__created_at__quarter + , subq_20.listing__created_at__year + , subq_20.listing__created_at__extract_year + , subq_20.listing__created_at__extract_quarter + , subq_20.listing__created_at__extract_month + , subq_20.listing__created_at__extract_day + , subq_20.listing__created_at__extract_dow + , subq_20.listing__created_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.user + , subq_20.listing__user + , subq_20.country_latest + , subq_20.is_lux_latest + , subq_20.capacity_latest + , subq_20.listing__country_latest + , subq_20.listing__is_lux_latest + , subq_20.listing__capacity_latest + , subq_20.listings + , subq_20.largest_listing + , subq_20.smallest_listing FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_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.created_at__day + , subq_19.created_at__week + , subq_19.created_at__month + , subq_19.created_at__quarter + , subq_19.created_at__year + , subq_19.created_at__extract_year + , subq_19.created_at__extract_quarter + , subq_19.created_at__extract_month + , subq_19.created_at__extract_day + , subq_19.created_at__extract_dow + , subq_19.created_at__extract_doy + , subq_19.listing__ds__day + , subq_19.listing__ds__week + , subq_19.listing__ds__month + , subq_19.listing__ds__quarter + , subq_19.listing__ds__year + , subq_19.listing__ds__extract_year + , subq_19.listing__ds__extract_quarter + , subq_19.listing__ds__extract_month + , subq_19.listing__ds__extract_day + , subq_19.listing__ds__extract_dow + , subq_19.listing__ds__extract_doy + , subq_19.listing__created_at__day + , subq_19.listing__created_at__week + , subq_19.listing__created_at__month + , subq_19.listing__created_at__quarter + , subq_19.listing__created_at__year + , subq_19.listing__created_at__extract_year + , subq_19.listing__created_at__extract_quarter + , subq_19.listing__created_at__extract_month + , subq_19.listing__created_at__extract_day + , subq_19.listing__created_at__extract_dow + , subq_19.listing__created_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.user + , subq_19.listing__user + , subq_19.country_latest + , subq_19.is_lux_latest + , subq_19.capacity_latest + , subq_19.listing__country_latest + , subq_19.listing__is_lux_latest + , subq_19.listing__capacity_latest + , subq_19.listings + , subq_19.largest_listing + , subq_19.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_6 - ) subq_7 - WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_8 - ) subq_9 - ) subq_10 -) subq_11 + , 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_19 + ) subq_20 + WHERE subq_20.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_21 + ) subq_22 + ) subq_23 +) subq_24 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 2691ca3c38..71a7d98121 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_17.bookings) AS bookings - , MAX(subq_23.listings) AS listings + MAX(subq_30.bookings) AS bookings + , MAX(subq_36.listings) AS listings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -11,9 +11,9 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_17 +) subq_30 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -23,6 +23,6 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_23 +) subq_36 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql index b8b5cc62a8..9d5463e01d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql @@ -1,241 +1,241 @@ -- Compute Metrics via Expressions SELECT - subq_7.user__home_state - , subq_7.identity_verifications + subq_16.user__home_state + , subq_16.identity_verifications FROM ( -- Aggregate Measures SELECT - subq_6.user__home_state - , SUM(subq_6.identity_verifications) AS identity_verifications + subq_15.user__home_state + , SUM(subq_15.identity_verifications) AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'user__home_state'] SELECT - subq_5.user__home_state - , subq_5.identity_verifications + subq_14.user__home_state + , subq_14.identity_verifications FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__day AS user__ds_partitioned__day - , subq_2.user AS user - , subq_4.home_state AS user__home_state - , subq_2.identity_verifications AS identity_verifications + subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__day AS user__ds_partitioned__day + , subq_11.user AS user + , subq_13.home_state AS user__home_state + , subq_11.identity_verifications AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT - subq_1.ds_partitioned__day - , subq_1.user - , subq_1.identity_verifications + subq_10.ds_partitioned__day + , subq_10.user + , subq_10.identity_verifications 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.verification__ds__day - , subq_0.verification__ds__week - , subq_0.verification__ds__month - , subq_0.verification__ds__quarter - , subq_0.verification__ds__year - , subq_0.verification__ds__extract_year - , subq_0.verification__ds__extract_quarter - , subq_0.verification__ds__extract_month - , subq_0.verification__ds__extract_day - , subq_0.verification__ds__extract_dow - , subq_0.verification__ds__extract_doy - , subq_0.verification__ds_partitioned__day - , subq_0.verification__ds_partitioned__week - , subq_0.verification__ds_partitioned__month - , subq_0.verification__ds_partitioned__quarter - , subq_0.verification__ds_partitioned__year - , subq_0.verification__ds_partitioned__extract_year - , subq_0.verification__ds_partitioned__extract_quarter - , subq_0.verification__ds_partitioned__extract_month - , subq_0.verification__ds_partitioned__extract_day - , subq_0.verification__ds_partitioned__extract_dow - , subq_0.verification__ds_partitioned__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.verification - , subq_0.user - , subq_0.verification__user - , subq_0.verification_type - , subq_0.verification__verification_type - , subq_0.identity_verifications + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.verification__ds__day + , subq_9.verification__ds__week + , subq_9.verification__ds__month + , subq_9.verification__ds__quarter + , subq_9.verification__ds__year + , subq_9.verification__ds__extract_year + , subq_9.verification__ds__extract_quarter + , subq_9.verification__ds__extract_month + , subq_9.verification__ds__extract_day + , subq_9.verification__ds__extract_dow + , subq_9.verification__ds__extract_doy + , subq_9.verification__ds_partitioned__day + , subq_9.verification__ds_partitioned__week + , subq_9.verification__ds_partitioned__month + , subq_9.verification__ds_partitioned__quarter + , subq_9.verification__ds_partitioned__year + , subq_9.verification__ds_partitioned__extract_year + , subq_9.verification__ds_partitioned__extract_quarter + , subq_9.verification__ds_partitioned__extract_month + , subq_9.verification__ds_partitioned__extract_day + , subq_9.verification__ds_partitioned__extract_dow + , subq_9.verification__ds_partitioned__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.verification + , subq_9.user + , subq_9.verification__user + , subq_9.verification_type + , subq_9.verification__verification_type + , subq_9.identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28004.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28004.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user - FROM ***************************.fct_id_verifications id_verifications_src_28004 - ) subq_0 - ) subq_1 - ) subq_2 + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28000.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user + FROM ***************************.fct_id_verifications id_verifications_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state', 'ds_partitioned__day', 'user'] SELECT - subq_3.ds_partitioned__day - , subq_3.user - , subq_3.home_state + subq_12.ds_partitioned__day + , subq_12.user + , subq_12.home_state FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - DATE_TRUNC('day', users_ds_source_src_28008.ds) AS ds__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds) AS ds__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds) AS ds__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds) AS ds__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds) AS ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28008.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds) AS ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.created_at) AS created_at__day - , DATE_TRUNC('week', users_ds_source_src_28008.created_at) AS created_at__week - , DATE_TRUNC('month', users_ds_source_src_28008.created_at) AS created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.created_at) AS created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.created_at) AS created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28008.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.created_at) AS created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state - , DATE_TRUNC('day', users_ds_source_src_28008.ds) AS user__ds__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds) AS user__ds__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds) AS user__ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS user__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28008.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds) AS user__ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.created_at) AS user__created_at__day - , DATE_TRUNC('week', users_ds_source_src_28008.created_at) AS user__created_at__week - , DATE_TRUNC('month', users_ds_source_src_28008.created_at) AS user__created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.created_at) AS user__created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.created_at) AS user__created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state AS user__home_state - , users_ds_source_src_28008.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28008 - ) subq_3 - ) subq_4 + DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_12 + ) subq_13 ON ( - subq_2.user = subq_4.user + subq_11.user = subq_13.user ) AND ( - subq_2.ds_partitioned__day = subq_4.ds_partitioned__day + subq_11.ds_partitioned__day = subq_13.ds_partitioned__day ) - ) subq_5 - ) subq_6 + ) subq_14 + ) subq_15 GROUP BY - subq_6.user__home_state -) subq_7 + subq_15.user__home_state +) subq_16 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql index 9f15f9bb3d..54ea641813 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql @@ -3,8 +3,8 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - users_ds_source_src_28008.home_state AS user__home_state - , SUM(subq_10.identity_verifications) AS identity_verifications + users_ds_source_src_28000.home_state AS user__home_state + , SUM(subq_19.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' -- Metric Time Dimension 'ds' @@ -13,15 +13,15 @@ FROM ( DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications - FROM ***************************.fct_id_verifications id_verifications_src_28004 -) subq_10 + FROM ***************************.fct_id_verifications id_verifications_src_28000 +) subq_19 LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_28008 + ***************************.dim_users users_ds_source_src_28000 ON ( - subq_10.user = users_ds_source_src_28008.user_id + subq_19.user = users_ds_source_src_28000.user_id ) AND ( - subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) + subq_19.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) ) GROUP BY - users_ds_source_src_28008.home_state + users_ds_source_src_28000.home_state diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0.sql index 4075567205..f5fb45927e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0.sql @@ -1,439 +1,439 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_value) AS booking_value + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 -) subq_4 + subq_11.metric_time__day + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_value) AS booking_value + subq_16.metric_time__day + , SUM(subq_16.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_value + subq_15.metric_time__day + , subq_15.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_16.metric_time__day + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0_optimized.sql index ccc0d8cd89..7831d40fe6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql index a1d54bfa48..cd3d4c172a 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql @@ -68,62 +68,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0_optimized.sql index 22b719da85..1653ada5bd 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_3 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0.sql index fce16f303c..5ce3103dde 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -1,383 +1,383 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_19.booking__is_instant + , subq_19.bookings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_18.booking__is_instant + , SUM(subq_18.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_17.booking__is_instant + , subq_17.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_16.booking__is_instant + , subq_16.listing__country_latest + , subq_16.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.booking__is_instant + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.listing + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__country_latest = 'us' - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_18.booking__is_instant +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index fdbb61ce0e..433c9799b5 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.country AS listing__country_latest - , subq_13.bookings AS bookings + subq_22.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.country AS listing__country_latest + , subq_22.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -20,13 +20,13 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28005.listing_id -) subq_18 + subq_22.listing = listings_latest_src_28000.listing_id +) subq_27 WHERE listing__country_latest = 'us' GROUP BY booking__is_instant diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0.sql index 96c20638a0..33edfd74b6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0.sql @@ -1,139 +1,139 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS family_bookings + subq_11.metric_time__day + , subq_11.bookings AS family_bookings FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_10.metric_time__day + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.listing__capacity - , subq_6.bookings + subq_8.metric_time__day + , subq_8.listing__capacity + , subq_8.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.listing__capacity - , subq_5.bookings + subq_7.metric_time__day + , subq_7.listing__capacity + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_4.window_start__day AS listing__window_start__day - , subq_4.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_4.capacity AS listing__capacity - , subq_2.bookings AS bookings + subq_4.metric_time__day AS metric_time__day + , subq_6.window_start__day AS listing__window_start__day + , subq_6.window_end__day AS listing__window_end__day + , subq_4.listing AS listing + , subq_6.capacity AS listing__capacity + , subq_4.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_3.metric_time__day + , subq_3.listing + , subq_3.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + 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.user + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.booking__user + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.bookers + , subq_2.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -220,94 +220,94 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_2 + ) subq_3 + ) subq_4 LEFT OUTER JOIN ( -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_3.window_start__day - , subq_3.window_end__day - , subq_3.listing - , subq_3.capacity + subq_5.window_start__day + , subq_5.window_end__day + , subq_5.listing + , subq_5.capacity FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 - ) subq_4 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_4.listing + subq_4.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_4.window_start__day + subq_4.metric_time__day >= subq_6.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_4.window_end__day + subq_4.metric_time__day < subq_6.window_end__day ) OR ( - subq_4.window_end__day IS NULL + subq_6.window_end__day IS NULL ) ) ) - ) subq_5 - ) subq_6 + ) subq_7 + ) subq_8 WHERE listing__capacity > 2 - ) subq_7 - ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_8.metric_time__day -) subq_9 + subq_10.metric_time__day +) subq_11 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0_optimized.sql index fc848091b1..0f3bd95cd6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_12.metric_time__day AS metric_time__day - , listings_src_26002.capacity AS listing__capacity - , subq_12.bookings AS bookings + subq_14.metric_time__day AS metric_time__day + , listings_src_26000.capacity AS listing__capacity + , subq_14.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -21,24 +21,24 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_12 + ) subq_14 LEFT OUTER JOIN - ***************************.dim_listings listings_src_26002 + ***************************.dim_listings listings_src_26000 ON ( - subq_12.listing = listings_src_26002.listing_id + subq_14.listing = listings_src_26000.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_26002.active_from + subq_14.metric_time__day >= listings_src_26000.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_26002.active_to + subq_14.metric_time__day < listings_src_26000.active_to ) OR ( - listings_src_26002.active_to IS NULL + listings_src_26000.active_to IS NULL ) ) ) -) subq_16 +) subq_18 WHERE listing__capacity > 2 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0.sql index f70d1c6eae..0cc25cd1eb 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0.sql @@ -1,220 +1,220 @@ -- Order By [] Limit 1 SELECT - subq_4.ds__day - , subq_4.bookings + subq_13.ds__day + , subq_13.bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.bookings + subq_12.ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.bookings + subq_10.ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__day - ) subq_3 -) subq_4 + subq_11.ds__day + ) subq_12 +) subq_13 LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0_optimized.sql index a71f7ae0e8..0780ad9c07 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0_optimized.sql @@ -11,8 +11,8 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_7 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_16 GROUP BY ds__day LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0.sql index a16164c267..c892fc3441 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0.sql @@ -1,150 +1,150 @@ -- Compute Metrics via Expressions SELECT - subq_3.listing__country_latest - , subq_3.listings + subq_12.listing__country_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_2.listing__country_latest - , SUM(subq_2.listings) AS listings + subq_11.listing__country_latest + , SUM(subq_11.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'listing__country_latest'] SELECT - subq_1.listing__country_latest - , subq_1.listings + subq_10.listing__country_latest + , subq_10.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.created_at__day - , subq_0.created_at__week - , subq_0.created_at__month - , subq_0.created_at__quarter - , subq_0.created_at__year - , subq_0.created_at__extract_year - , subq_0.created_at__extract_quarter - , subq_0.created_at__extract_month - , subq_0.created_at__extract_day - , subq_0.created_at__extract_dow - , subq_0.created_at__extract_doy - , subq_0.listing__ds__day - , subq_0.listing__ds__week - , subq_0.listing__ds__month - , subq_0.listing__ds__quarter - , subq_0.listing__ds__year - , subq_0.listing__ds__extract_year - , subq_0.listing__ds__extract_quarter - , subq_0.listing__ds__extract_month - , subq_0.listing__ds__extract_day - , subq_0.listing__ds__extract_dow - , subq_0.listing__ds__extract_doy - , subq_0.listing__created_at__day - , subq_0.listing__created_at__week - , subq_0.listing__created_at__month - , subq_0.listing__created_at__quarter - , subq_0.listing__created_at__year - , subq_0.listing__created_at__extract_year - , subq_0.listing__created_at__extract_quarter - , subq_0.listing__created_at__extract_month - , subq_0.listing__created_at__extract_day - , subq_0.listing__created_at__extract_dow - , subq_0.listing__created_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.user - , subq_0.listing__user - , subq_0.country_latest - , subq_0.is_lux_latest - , subq_0.capacity_latest - , subq_0.listing__country_latest - , subq_0.listing__is_lux_latest - , subq_0.listing__capacity_latest - , subq_0.listings - , subq_0.largest_listing - , subq_0.smallest_listing + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.listing__country_latest -) subq_3 + subq_11.listing__country_latest +) subq_12 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0_optimized.sql index 8486e86449..c0733d39a6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT country AS listing__country_latest , 1 AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_6 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_15 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql index 5564f9e3a9..a3fa71afd3 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql @@ -1,1003 +1,1003 @@ -- Compute Metrics via Expressions SELECT - subq_29.metric_time__day + subq_38.metric_time__day , average_booking_value * bookings / NULLIF(booking_value, 0) AS lux_booking_value_rate_expr FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_28.booking_value) AS booking_value + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_37.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_19.metric_time__day + , subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , AVG(subq_9.average_booking_value) AS average_booking_value + subq_18.metric_time__day + , AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_17.metric_time__day + , subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.metric_time__day + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.metric_time__day + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.average_booking_value AS average_booking_value + subq_11.metric_time__day AS metric_time__day + , subq_11.listing AS listing + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.average_booking_value + subq_10.metric_time__day + , subq_10.listing + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_18.metric_time__day + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day - , subq_22.bookings + subq_31.metric_time__day + , subq_31.bookings FROM ( -- Aggregate Measures SELECT - subq_21.metric_time__day - , SUM(subq_21.bookings) AS bookings + subq_30.metric_time__day + , SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.metric_time__day + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.metric_time__day + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.metric_time__day AS metric_time__day + , subq_23.listing AS listing + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.bookings + subq_22.metric_time__day + , subq_22.listing + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE listing__is_lux_latest - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 GROUP BY - subq_21.metric_time__day - ) subq_22 - ) subq_23 + subq_30.metric_time__day + ) subq_31 + ) subq_32 ON - subq_11.metric_time__day = subq_23.metric_time__day + subq_20.metric_time__day = subq_32.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.booking_value + subq_36.metric_time__day + , subq_36.booking_value FROM ( -- Aggregate Measures SELECT - subq_26.metric_time__day - , SUM(subq_26.booking_value) AS booking_value + subq_35.metric_time__day + , SUM(subq_35.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_25.metric_time__day - , subq_25.booking_value + subq_34.metric_time__day + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 GROUP BY - subq_26.metric_time__day - ) subq_27 - ) subq_28 + subq_35.metric_time__day + ) subq_36 + ) subq_37 ON - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day) = subq_37.metric_time__day GROUP BY - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) -) subq_29 + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day, subq_37.metric_time__day) +) subq_38 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql index 69ba3892a2..91ab825138 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) AS metric_time__day - , MAX(subq_41.average_booking_value) AS average_booking_value - , MAX(subq_53.bookings) AS bookings - , MAX(subq_58.booking_value) AS booking_value + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day, subq_67.metric_time__day) AS metric_time__day + , MAX(subq_50.average_booking_value) AS average_booking_value + , MAX(subq_62.bookings) AS bookings + , MAX(subq_67.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -21,19 +21,19 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - DATE_TRUNC('day', bookings_source_src_28001.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + DATE_TRUNC('day', bookings_source_src_28000.ds) AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_37 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_46 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_41 + ) subq_50 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -46,9 +46,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_44.metric_time__day AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_44.bookings AS bookings + subq_53.metric_time__day AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_53.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -57,19 +57,19 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_44 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_53 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_44.listing = listings_latest_src_28005.listing_id - ) subq_49 + subq_53.listing = listings_latest_src_28000.listing_id + ) subq_58 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_53 + ) subq_62 ON - subq_41.metric_time__day = subq_53.metric_time__day + subq_50.metric_time__day = subq_62.metric_time__day FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -79,12 +79,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_58 + ) subq_67 ON - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day) = subq_58.metric_time__day + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day) = subq_67.metric_time__day GROUP BY - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) -) subq_59 + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day, subq_67.metric_time__day) +) subq_68 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql index fa5987a04a..898b8f5500 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,460 +1,460 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , CAST(subq_12.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_12.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio + subq_21.metric_time__day + , CAST(subq_21.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_21.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , MAX(subq_6.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_11.booking_value) AS booking_value + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day + , MAX(subq_15.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_20.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.booking_value AS booking_value_with_is_instant_constraint + subq_14.metric_time__day + , subq_14.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.booking_value) AS booking_value + subq_13.metric_time__day + , SUM(subq_13.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.booking_value + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_13.metric_time__day + ) subq_14 + ) subq_15 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_19.metric_time__day + , subq_19.booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.booking_value) AS booking_value + subq_18.metric_time__day + , SUM(subq_18.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.ds_partitioned__day + , subq_16.ds_partitioned__week + , subq_16.ds_partitioned__month + , subq_16.ds_partitioned__quarter + , subq_16.ds_partitioned__year + , subq_16.ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy + , subq_16.paid_at__day + , subq_16.paid_at__week + , subq_16.paid_at__month + , subq_16.paid_at__quarter + , subq_16.paid_at__year + , subq_16.paid_at__extract_year + , subq_16.paid_at__extract_quarter + , subq_16.paid_at__extract_month + , subq_16.paid_at__extract_day + , subq_16.paid_at__extract_dow + , subq_16.paid_at__extract_doy + , subq_16.booking__ds__day + , subq_16.booking__ds__week + , subq_16.booking__ds__month + , subq_16.booking__ds__quarter + , subq_16.booking__ds__year + , subq_16.booking__ds__extract_year + , subq_16.booking__ds__extract_quarter + , subq_16.booking__ds__extract_month + , subq_16.booking__ds__extract_day + , subq_16.booking__ds__extract_dow + , subq_16.booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day + , subq_16.booking__paid_at__week + , subq_16.booking__paid_at__month + , subq_16.booking__paid_at__quarter + , subq_16.booking__paid_at__year + , subq_16.booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.listing + , subq_16.guest + , subq_16.host + , subq_16.booking__listing + , subq_16.booking__guest + , subq_16.booking__host + , subq_16.is_instant + , subq_16.booking__is_instant + , subq_16.bookings + , subq_16.instant_bookings + , subq_16.booking_value + , subq_16.max_booking_value + , subq_16.min_booking_value + , subq_16.bookers + , subq_16.average_booking_value + , subq_16.referred_bookings + , subq_16.median_booking_value + , subq_16.booking_value_p99 + , subq_16.discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 + , subq_16.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_7 - ) subq_8 - ) subq_9 + , 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_16 + ) subq_17 + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_18.metric_time__day + ) subq_19 + ) subq_20 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_15.metric_time__day = subq_20.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) +) subq_21 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql index d384201243..e6c18549b2 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , MAX(subq_19.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_24.booking_value) AS booking_value + COALESCE(subq_28.metric_time__day, subq_33.metric_time__day) AS metric_time__day + , MAX(subq_28.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_33.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_28 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -39,12 +39,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_33 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_28.metric_time__day = subq_33.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_28.metric_time__day, subq_33.metric_time__day) +) subq_34 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 5c2c621376..ea8c9d8383 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,234 +1,234 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day + subq_15.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.bookings AS delayed_bookings + subq_14.metric_time__day + , subq_14.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_13.metric_time__day + , SUM(subq_13.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE NOT booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY - subq_4.metric_time__day - ) subq_5 -) subq_6 + subq_13.metric_time__day + ) subq_14 +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index df414b0013..c494772d25 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -18,9 +18,9 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index e3ba21dd52..752349793d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -1,366 +1,366 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_10.bookings AS DOUBLE) / CAST(NULLIF(subq_10.listings, 0) AS DOUBLE) AS bookings_per_listing + CAST(subq_19.bookings AS DOUBLE) / CAST(NULLIF(subq_19.listings, 0) AS DOUBLE) AS bookings_per_listing FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_4.bookings) AS bookings - , MAX(subq_9.listings) AS listings + MAX(subq_13.bookings) AS bookings + , MAX(subq_18.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.bookings + subq_12.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_2.bookings) AS bookings + SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_1.bookings + subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 - ) subq_4 + , 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_9 + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.listings + subq_17.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_7.listings) AS listings + SUM(subq_16.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_6.listings + subq_15.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.created_at__day - , subq_5.created_at__week - , subq_5.created_at__month - , subq_5.created_at__quarter - , subq_5.created_at__year - , subq_5.created_at__extract_year - , subq_5.created_at__extract_quarter - , subq_5.created_at__extract_month - , subq_5.created_at__extract_day - , subq_5.created_at__extract_dow - , subq_5.created_at__extract_doy - , subq_5.listing__ds__day - , subq_5.listing__ds__week - , subq_5.listing__ds__month - , subq_5.listing__ds__quarter - , subq_5.listing__ds__year - , subq_5.listing__ds__extract_year - , subq_5.listing__ds__extract_quarter - , subq_5.listing__ds__extract_month - , subq_5.listing__ds__extract_day - , subq_5.listing__ds__extract_dow - , subq_5.listing__ds__extract_doy - , subq_5.listing__created_at__day - , subq_5.listing__created_at__week - , subq_5.listing__created_at__month - , subq_5.listing__created_at__quarter - , subq_5.listing__created_at__year - , subq_5.listing__created_at__extract_year - , subq_5.listing__created_at__extract_quarter - , subq_5.listing__created_at__extract_month - , subq_5.listing__created_at__extract_day - , subq_5.listing__created_at__extract_dow - , subq_5.listing__created_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.user - , subq_5.listing__user - , subq_5.country_latest - , subq_5.is_lux_latest - , subq_5.capacity_latest - , subq_5.listing__country_latest - , subq_5.listing__is_lux_latest - , subq_5.listing__capacity_latest - , subq_5.listings - , subq_5.largest_listing - , subq_5.smallest_listing + 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.created_at__day + , subq_14.created_at__week + , subq_14.created_at__month + , subq_14.created_at__quarter + , subq_14.created_at__year + , subq_14.created_at__extract_year + , subq_14.created_at__extract_quarter + , subq_14.created_at__extract_month + , subq_14.created_at__extract_day + , subq_14.created_at__extract_dow + , subq_14.created_at__extract_doy + , subq_14.listing__ds__day + , subq_14.listing__ds__week + , subq_14.listing__ds__month + , subq_14.listing__ds__quarter + , subq_14.listing__ds__year + , subq_14.listing__ds__extract_year + , subq_14.listing__ds__extract_quarter + , subq_14.listing__ds__extract_month + , subq_14.listing__ds__extract_day + , subq_14.listing__ds__extract_dow + , subq_14.listing__ds__extract_doy + , subq_14.listing__created_at__day + , subq_14.listing__created_at__week + , subq_14.listing__created_at__month + , subq_14.listing__created_at__quarter + , subq_14.listing__created_at__year + , subq_14.listing__created_at__extract_year + , subq_14.listing__created_at__extract_quarter + , subq_14.listing__created_at__extract_month + , subq_14.listing__created_at__extract_day + , subq_14.listing__created_at__extract_dow + , subq_14.listing__created_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.user + , subq_14.listing__user + , subq_14.country_latest + , subq_14.is_lux_latest + , subq_14.capacity_latest + , subq_14.listing__country_latest + , subq_14.listing__is_lux_latest + , subq_14.listing__capacity_latest + , subq_14.listings + , subq_14.largest_listing + , subq_14.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_5 - ) subq_6 - ) subq_7 - ) subq_8 - ) subq_9 -) subq_10 + , 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_14 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index 13f8ff2353..c293244ecc 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_15.bookings) AS DOUBLE) / CAST(NULLIF(MAX(subq_20.listings), 0) AS DOUBLE) AS bookings_per_listing + CAST(MAX(subq_24.bookings) AS DOUBLE) / CAST(NULLIF(MAX(subq_29.listings), 0) AS DOUBLE) AS bookings_per_listing FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -10,8 +10,8 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_24 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -20,5 +20,5 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_20 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_29 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_categorical__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_categorical__plan0.sql index f5a38c336c..c8c44e9886 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_categorical__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_categorical__plan0.sql @@ -10,62 +10,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 GROUP BY subq_0.listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_categorical__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_categorical__plan0_optimized.sql index c1da0c0382..a8d1afa6a8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_categorical__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_categorical__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 GROUP BY country ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time__plan0.sql index 3bce77fb28..0675d4b77f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY subq_0.booking__paid_at__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time__plan0_optimized.sql index 280b915894..e6a861c58f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__day',] SELECT DATE_TRUNC('day', paid_at) AS booking__paid_at__day - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', paid_at) ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time_quarter__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time_quarter__plan0.sql index 53624696bc..1f038042ce 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time_quarter__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time_quarter__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY subq_0.booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time_quarter__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time_quarter__plan0_optimized.sql index f6d583edbe..5ff0fa4feb 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time_quarter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_min_max_only_time_quarter__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__quarter',] SELECT DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('quarter', paid_at) ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0.sql index 25db7e1f1e..6c08f405fc 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__user__home_state_latest - , subq_10.bookings + subq_23.metric_time__day + , subq_23.listing__user__home_state_latest + , subq_23.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest - , SUM(subq_9.bookings) AS bookings + subq_22.metric_time__day + , subq_22.listing__user__home_state_latest + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__home_state_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__user__home_state_latest - , subq_8.bookings + subq_21.metric_time__day + , subq_21.listing__user__home_state_latest + , subq_21.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.window_start__day AS listing__window_start__day - , subq_7.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_7.user__home_state_latest AS listing__user__home_state_latest - , subq_2.bookings AS bookings + subq_15.metric_time__day AS metric_time__day + , subq_20.window_start__day AS listing__window_start__day + , subq_20.window_end__day AS listing__window_end__day + , subq_15.listing AS listing + , subq_20.user__home_state_latest AS listing__user__home_state_latest + , subq_15.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_14.metric_time__day + , subq_14.listing + , subq_14.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.user + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.booking__user + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.bookers + , subq_13.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,142 +211,142 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_13 + ) subq_14 + ) subq_15 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_6.window_start__day - , subq_6.window_end__day - , subq_6.listing - , subq_6.user__home_state_latest + subq_19.window_start__day + , subq_19.window_end__day + , subq_19.listing + , subq_19.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_3.window_start__day AS window_start__day - , subq_3.window_start__week AS window_start__week - , subq_3.window_start__month AS window_start__month - , subq_3.window_start__quarter AS window_start__quarter - , subq_3.window_start__year AS window_start__year - , subq_3.window_start__extract_year AS window_start__extract_year - , subq_3.window_start__extract_quarter AS window_start__extract_quarter - , subq_3.window_start__extract_month AS window_start__extract_month - , subq_3.window_start__extract_day AS window_start__extract_day - , subq_3.window_start__extract_dow AS window_start__extract_dow - , subq_3.window_start__extract_doy AS window_start__extract_doy - , subq_3.window_end__day AS window_end__day - , subq_3.window_end__week AS window_end__week - , subq_3.window_end__month AS window_end__month - , subq_3.window_end__quarter AS window_end__quarter - , subq_3.window_end__year AS window_end__year - , subq_3.window_end__extract_year AS window_end__extract_year - , subq_3.window_end__extract_quarter AS window_end__extract_quarter - , subq_3.window_end__extract_month AS window_end__extract_month - , subq_3.window_end__extract_day AS window_end__extract_day - , subq_3.window_end__extract_dow AS window_end__extract_dow - , subq_3.window_end__extract_doy AS window_end__extract_doy - , subq_3.listing__window_start__day AS listing__window_start__day - , subq_3.listing__window_start__week AS listing__window_start__week - , subq_3.listing__window_start__month AS listing__window_start__month - , subq_3.listing__window_start__quarter AS listing__window_start__quarter - , subq_3.listing__window_start__year AS listing__window_start__year - , subq_3.listing__window_start__extract_year AS listing__window_start__extract_year - , subq_3.listing__window_start__extract_quarter AS listing__window_start__extract_quarter - , subq_3.listing__window_start__extract_month AS listing__window_start__extract_month - , subq_3.listing__window_start__extract_day AS listing__window_start__extract_day - , subq_3.listing__window_start__extract_dow AS listing__window_start__extract_dow - , subq_3.listing__window_start__extract_doy AS listing__window_start__extract_doy - , subq_3.listing__window_end__day AS listing__window_end__day - , subq_3.listing__window_end__week AS listing__window_end__week - , subq_3.listing__window_end__month AS listing__window_end__month - , subq_3.listing__window_end__quarter AS listing__window_end__quarter - , subq_3.listing__window_end__year AS listing__window_end__year - , subq_3.listing__window_end__extract_year AS listing__window_end__extract_year - , subq_3.listing__window_end__extract_quarter AS listing__window_end__extract_quarter - , subq_3.listing__window_end__extract_month AS listing__window_end__extract_month - , subq_3.listing__window_end__extract_day AS listing__window_end__extract_day - , subq_3.listing__window_end__extract_dow AS listing__window_end__extract_dow - , subq_3.listing__window_end__extract_doy AS listing__window_end__extract_doy - , subq_5.ds__day AS user__ds__day - , subq_5.ds__week AS user__ds__week - , subq_5.ds__month AS user__ds__month - , subq_5.ds__quarter AS user__ds__quarter - , subq_5.ds__year AS user__ds__year - , subq_5.ds__extract_year AS user__ds__extract_year - , subq_5.ds__extract_quarter AS user__ds__extract_quarter - , subq_5.ds__extract_month AS user__ds__extract_month - , subq_5.ds__extract_day AS user__ds__extract_day - , subq_5.ds__extract_dow AS user__ds__extract_dow - , subq_5.ds__extract_doy AS user__ds__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country AS country - , subq_3.is_lux AS is_lux - , subq_3.capacity AS capacity - , subq_3.listing__country AS listing__country - , subq_3.listing__is_lux AS listing__is_lux - , subq_3.listing__capacity AS listing__capacity - , subq_5.home_state_latest AS user__home_state_latest + subq_16.window_start__day AS window_start__day + , subq_16.window_start__week AS window_start__week + , subq_16.window_start__month AS window_start__month + , subq_16.window_start__quarter AS window_start__quarter + , subq_16.window_start__year AS window_start__year + , subq_16.window_start__extract_year AS window_start__extract_year + , subq_16.window_start__extract_quarter AS window_start__extract_quarter + , subq_16.window_start__extract_month AS window_start__extract_month + , subq_16.window_start__extract_day AS window_start__extract_day + , subq_16.window_start__extract_dow AS window_start__extract_dow + , subq_16.window_start__extract_doy AS window_start__extract_doy + , subq_16.window_end__day AS window_end__day + , subq_16.window_end__week AS window_end__week + , subq_16.window_end__month AS window_end__month + , subq_16.window_end__quarter AS window_end__quarter + , subq_16.window_end__year AS window_end__year + , subq_16.window_end__extract_year AS window_end__extract_year + , subq_16.window_end__extract_quarter AS window_end__extract_quarter + , subq_16.window_end__extract_month AS window_end__extract_month + , subq_16.window_end__extract_day AS window_end__extract_day + , subq_16.window_end__extract_dow AS window_end__extract_dow + , subq_16.window_end__extract_doy AS window_end__extract_doy + , subq_16.listing__window_start__day AS listing__window_start__day + , subq_16.listing__window_start__week AS listing__window_start__week + , subq_16.listing__window_start__month AS listing__window_start__month + , subq_16.listing__window_start__quarter AS listing__window_start__quarter + , subq_16.listing__window_start__year AS listing__window_start__year + , subq_16.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_16.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_16.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_16.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_16.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_16.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_16.listing__window_end__day AS listing__window_end__day + , subq_16.listing__window_end__week AS listing__window_end__week + , subq_16.listing__window_end__month AS listing__window_end__month + , subq_16.listing__window_end__quarter AS listing__window_end__quarter + , subq_16.listing__window_end__year AS listing__window_end__year + , subq_16.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_16.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_16.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_16.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_16.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_16.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_18.ds__day AS user__ds__day + , subq_18.ds__week AS user__ds__week + , subq_18.ds__month AS user__ds__month + , subq_18.ds__quarter AS user__ds__quarter + , subq_18.ds__year AS user__ds__year + , subq_18.ds__extract_year AS user__ds__extract_year + , subq_18.ds__extract_quarter AS user__ds__extract_quarter + , subq_18.ds__extract_month AS user__ds__extract_month + , subq_18.ds__extract_day AS user__ds__extract_day + , subq_18.ds__extract_dow AS user__ds__extract_dow + , subq_18.ds__extract_doy AS user__ds__extract_doy + , subq_16.listing AS listing + , subq_16.user AS user + , subq_16.listing__user AS listing__user + , subq_16.country AS country + , subq_16.is_lux AS is_lux + , subq_16.capacity AS capacity + , subq_16.listing__country AS listing__country + , subq_16.listing__is_lux AS listing__is_lux + , subq_16.listing__capacity AS listing__capacity + , subq_18.home_state_latest AS user__home_state_latest FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_16 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,83 +376,83 @@ FROM ( -- 'user', -- ] SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.user__ds__day - , subq_4.user__ds__week - , subq_4.user__ds__month - , subq_4.user__ds__quarter - , subq_4.user__ds__year - , subq_4.user__ds__extract_year - , subq_4.user__ds__extract_quarter - , subq_4.user__ds__extract_month - , subq_4.user__ds__extract_day - , subq_4.user__ds__extract_dow - , subq_4.user__ds__extract_doy - , subq_4.user - , subq_4.home_state_latest - , subq_4.user__home_state_latest + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.user__ds__day + , subq_17.user__ds__week + , subq_17.user__ds__month + , subq_17.user__ds__quarter + , subq_17.user__ds__year + , subq_17.user__ds__extract_year + , subq_17.user__ds__extract_quarter + , subq_17.user__ds__extract_month + , subq_17.user__ds__extract_day + , subq_17.user__ds__extract_dow + , subq_17.user__ds__extract_doy + , subq_17.user + , subq_17.home_state_latest + , subq_17.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_26006.ds) AS ds__day - , DATE_TRUNC('week', users_latest_src_26006.ds) AS ds__week - , DATE_TRUNC('month', users_latest_src_26006.ds) AS ds__month - , DATE_TRUNC('quarter', users_latest_src_26006.ds) AS ds__quarter - , DATE_TRUNC('year', users_latest_src_26006.ds) AS ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS ds__extract_day - , EXTRACT(isodow FROM users_latest_src_26006.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_latest_src_26006.ds) AS ds__extract_doy - , users_latest_src_26006.home_state_latest - , DATE_TRUNC('day', users_latest_src_26006.ds) AS user__ds__day - , DATE_TRUNC('week', users_latest_src_26006.ds) AS user__ds__week - , DATE_TRUNC('month', users_latest_src_26006.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_latest_src_26006.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_latest_src_26006.ds) AS user__ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS user__ds__extract_day - , EXTRACT(isodow FROM users_latest_src_26006.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_latest_src_26006.ds) AS user__ds__extract_doy - , users_latest_src_26006.home_state_latest AS user__home_state_latest - , users_latest_src_26006.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_26006 - ) subq_4 - ) subq_5 + DATE_TRUNC('day', users_latest_src_26000.ds) AS ds__day + , DATE_TRUNC('week', users_latest_src_26000.ds) AS ds__week + , DATE_TRUNC('month', users_latest_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', users_latest_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', users_latest_src_26000.ds) AS ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_latest_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_latest_src_26000.ds) AS ds__extract_doy + , users_latest_src_26000.home_state_latest + , DATE_TRUNC('day', users_latest_src_26000.ds) AS user__ds__day + , DATE_TRUNC('week', users_latest_src_26000.ds) AS user__ds__week + , DATE_TRUNC('month', users_latest_src_26000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_latest_src_26000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_latest_src_26000.ds) AS user__ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_latest_src_26000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_latest_src_26000.ds) AS user__ds__extract_doy + , users_latest_src_26000.home_state_latest AS user__home_state_latest + , users_latest_src_26000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_26000 + ) subq_17 + ) subq_18 ON - subq_3.user = subq_5.user - ) subq_6 - ) subq_7 + subq_16.user = subq_18.user + ) subq_19 + ) subq_20 ON ( - subq_2.listing = subq_7.listing + subq_15.listing = subq_20.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.window_start__day + subq_15.metric_time__day >= subq_20.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.window_end__day + subq_15.metric_time__day < subq_20.window_end__day ) OR ( - subq_7.window_end__day IS NULL + subq_20.window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_21 + ) subq_22 GROUP BY - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest -) subq_10 + subq_22.metric_time__day + , subq_22.listing__user__home_state_latest +) subq_23 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 1d7e6c24a7..f38afda4f7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.user__home_state_latest AS listing__user__home_state_latest - , SUM(subq_13.bookings) AS bookings + subq_26.metric_time__day AS metric_time__day + , subq_31.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_26.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,35 +15,35 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_26 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - listings_src_26002.active_from AS window_start__day - , listings_src_26002.active_to AS window_end__day - , listings_src_26002.listing_id AS listing - , users_latest_src_26006.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings listings_src_26002 + listings_src_26000.active_from AS window_start__day + , listings_src_26000.active_to AS window_end__day + , listings_src_26000.listing_id AS listing + , users_latest_src_26000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings listings_src_26000 LEFT OUTER JOIN - ***************************.dim_users_latest users_latest_src_26006 + ***************************.dim_users_latest users_latest_src_26000 ON - listings_src_26002.user_id = users_latest_src_26006.user_id -) subq_18 + listings_src_26000.user_id = users_latest_src_26000.user_id +) subq_31 ON ( - subq_13.listing = subq_18.listing + subq_26.listing = subq_31.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_26.metric_time__day >= subq_31.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_26.metric_time__day < subq_31.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_31.window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.user__home_state_latest + subq_26.metric_time__day + , subq_31.user__home_state_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0.sql index 98c67a81c2..b44d8b709b 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__lux_listing__is_confirmed_lux - , subq_10.bookings + subq_15.metric_time__day + , subq_15.listing__lux_listing__is_confirmed_lux + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux - , SUM(subq_9.bookings) AS bookings + subq_14.metric_time__day + , subq_14.listing__lux_listing__is_confirmed_lux + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__lux_listing__is_confirmed_lux', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__lux_listing__is_confirmed_lux - , subq_8.bookings + subq_13.metric_time__day + , subq_13.listing__lux_listing__is_confirmed_lux + , subq_13.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.lux_listing__window_start__day AS listing__lux_listing__window_start__day - , subq_7.lux_listing__window_end__day AS listing__lux_listing__window_end__day - , subq_2.listing AS listing - , subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , subq_2.bookings AS bookings + subq_7.metric_time__day AS metric_time__day + , subq_12.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_12.lux_listing__window_end__day AS listing__lux_listing__window_end__day + , subq_7.listing AS listing + , subq_12.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_7.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_6.metric_time__day + , subq_6.listing + , subq_6.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.ds__day AS metric_time__day + , subq_5.ds__week AS metric_time__week + , subq_5.ds__month AS metric_time__month + , subq_5.ds__quarter AS metric_time__quarter + , subq_5.ds__year AS metric_time__year + , subq_5.ds__extract_year AS metric_time__extract_year + , subq_5.ds__extract_quarter AS metric_time__extract_quarter + , subq_5.ds__extract_month AS metric_time__extract_month + , subq_5.ds__extract_day AS metric_time__extract_day + , subq_5.ds__extract_dow AS metric_time__extract_dow + , subq_5.ds__extract_doy AS metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.user + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.booking__user + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.bookings + , subq_5.instant_bookings + , subq_5.booking_value + , subq_5.bookers + , subq_5.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,53 +211,53 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_5 + ) subq_6 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - subq_6.lux_listing__window_start__day - , subq_6.lux_listing__window_end__day - , subq_6.listing - , subq_6.lux_listing__is_confirmed_lux + subq_11.lux_listing__window_start__day + , subq_11.lux_listing__window_end__day + , subq_11.listing + , subq_11.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_5.window_start__day AS lux_listing__window_start__day - , subq_5.window_start__week AS lux_listing__window_start__week - , subq_5.window_start__month AS lux_listing__window_start__month - , subq_5.window_start__quarter AS lux_listing__window_start__quarter - , subq_5.window_start__year AS lux_listing__window_start__year - , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_5.window_end__day AS lux_listing__window_end__day - , subq_5.window_end__week AS lux_listing__window_end__week - , subq_5.window_end__month AS lux_listing__window_end__month - , subq_5.window_end__quarter AS lux_listing__window_end__quarter - , subq_5.window_end__year AS lux_listing__window_end__year - , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_3.listing AS listing - , subq_3.lux_listing AS lux_listing - , subq_3.listing__lux_listing AS listing__lux_listing - , subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux + subq_10.window_start__day AS lux_listing__window_start__day + , subq_10.window_start__week AS lux_listing__window_start__week + , subq_10.window_start__month AS lux_listing__window_start__month + , subq_10.window_start__quarter AS lux_listing__window_start__quarter + , subq_10.window_start__year AS lux_listing__window_start__year + , subq_10.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_10.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_10.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_10.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_10.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_10.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_10.window_end__day AS lux_listing__window_end__day + , subq_10.window_end__week AS lux_listing__window_end__week + , subq_10.window_end__month AS lux_listing__window_end__month + , subq_10.window_end__quarter AS lux_listing__window_end__quarter + , subq_10.window_end__year AS lux_listing__window_end__year + , subq_10.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_10.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_10.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_10.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_10.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_10.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_8.listing AS listing + , subq_8.lux_listing AS lux_listing + , subq_8.listing__lux_listing AS listing__lux_listing + , subq_10.is_confirmed_lux AS lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT - lux_listing_mapping_src_26003.listing_id AS listing - , lux_listing_mapping_src_26003.lux_listing_id AS lux_listing - , lux_listing_mapping_src_26003.lux_listing_id AS listing__lux_listing - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 - ) subq_3 + lux_listing_mapping_src_26000.listing_id AS listing + , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing + , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 + ) subq_8 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,127 +309,127 @@ FROM ( -- 'lux_listing', -- ] SELECT - subq_4.window_start__day - , subq_4.window_start__week - , subq_4.window_start__month - , subq_4.window_start__quarter - , subq_4.window_start__year - , subq_4.window_start__extract_year - , subq_4.window_start__extract_quarter - , subq_4.window_start__extract_month - , subq_4.window_start__extract_day - , subq_4.window_start__extract_dow - , subq_4.window_start__extract_doy - , subq_4.window_end__day - , subq_4.window_end__week - , subq_4.window_end__month - , subq_4.window_end__quarter - , subq_4.window_end__year - , subq_4.window_end__extract_year - , subq_4.window_end__extract_quarter - , subq_4.window_end__extract_month - , subq_4.window_end__extract_day - , subq_4.window_end__extract_dow - , subq_4.window_end__extract_doy - , subq_4.lux_listing__window_start__day - , subq_4.lux_listing__window_start__week - , subq_4.lux_listing__window_start__month - , subq_4.lux_listing__window_start__quarter - , subq_4.lux_listing__window_start__year - , subq_4.lux_listing__window_start__extract_year - , subq_4.lux_listing__window_start__extract_quarter - , subq_4.lux_listing__window_start__extract_month - , subq_4.lux_listing__window_start__extract_day - , subq_4.lux_listing__window_start__extract_dow - , subq_4.lux_listing__window_start__extract_doy - , subq_4.lux_listing__window_end__day - , subq_4.lux_listing__window_end__week - , subq_4.lux_listing__window_end__month - , subq_4.lux_listing__window_end__quarter - , subq_4.lux_listing__window_end__year - , subq_4.lux_listing__window_end__extract_year - , subq_4.lux_listing__window_end__extract_quarter - , subq_4.lux_listing__window_end__extract_month - , subq_4.lux_listing__window_end__extract_day - , subq_4.lux_listing__window_end__extract_dow - , subq_4.lux_listing__window_end__extract_doy - , subq_4.lux_listing - , subq_4.is_confirmed_lux - , subq_4.lux_listing__is_confirmed_lux + subq_9.window_start__day + , subq_9.window_start__week + , subq_9.window_start__month + , subq_9.window_start__quarter + , subq_9.window_start__year + , subq_9.window_start__extract_year + , subq_9.window_start__extract_quarter + , subq_9.window_start__extract_month + , subq_9.window_start__extract_day + , subq_9.window_start__extract_dow + , subq_9.window_start__extract_doy + , subq_9.window_end__day + , subq_9.window_end__week + , subq_9.window_end__month + , subq_9.window_end__quarter + , subq_9.window_end__year + , subq_9.window_end__extract_year + , subq_9.window_end__extract_quarter + , subq_9.window_end__extract_month + , subq_9.window_end__extract_day + , subq_9.window_end__extract_dow + , subq_9.window_end__extract_doy + , subq_9.lux_listing__window_start__day + , subq_9.lux_listing__window_start__week + , subq_9.lux_listing__window_start__month + , subq_9.lux_listing__window_start__quarter + , subq_9.lux_listing__window_start__year + , subq_9.lux_listing__window_start__extract_year + , subq_9.lux_listing__window_start__extract_quarter + , subq_9.lux_listing__window_start__extract_month + , subq_9.lux_listing__window_start__extract_day + , subq_9.lux_listing__window_start__extract_dow + , subq_9.lux_listing__window_start__extract_doy + , subq_9.lux_listing__window_end__day + , subq_9.lux_listing__window_end__week + , subq_9.lux_listing__window_end__month + , subq_9.lux_listing__window_end__quarter + , subq_9.lux_listing__window_end__year + , subq_9.lux_listing__window_end__extract_year + , subq_9.lux_listing__window_end__extract_quarter + , subq_9.lux_listing__window_end__extract_month + , subq_9.lux_listing__window_end__extract_day + , subq_9.lux_listing__window_end__extract_dow + , subq_9.lux_listing__window_end__extract_doy + , subq_9.lux_listing + , subq_9.is_confirmed_lux + , subq_9.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT - lux_listings_src_26004.valid_from AS window_start__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_from) AS window_start__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_from) AS window_start__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_from) AS window_start__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_from) AS window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS window_start__extract_day - , EXTRACT(isodow FROM lux_listings_src_26004.valid_from) AS window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_from) AS window_start__extract_doy - , lux_listings_src_26004.valid_to AS window_end__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_to) AS window_end__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_to) AS window_end__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_to) AS window_end__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_to) AS window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS window_end__extract_day - , EXTRACT(isodow FROM lux_listings_src_26004.valid_to) AS window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_to) AS window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux - , lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_from) AS lux_listing__window_start__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_from) AS lux_listing__window_start__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_from) AS lux_listing__window_start__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_from) AS lux_listing__window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_day - , EXTRACT(isodow FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_doy - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_to) AS lux_listing__window_end__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_to) AS lux_listing__window_end__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_to) AS lux_listing__window_end__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_to) AS lux_listing__window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_day - , EXTRACT(isodow FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - , lux_listings_src_26004.lux_listing_id AS lux_listing - FROM ***************************.dim_lux_listings lux_listings_src_26004 - ) subq_4 - ) subq_5 + lux_listings_src_26000.valid_from AS window_start__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_from) AS window_start__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_from) AS window_start__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_from) AS window_start__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_from) AS window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS window_start__extract_day + , EXTRACT(isodow FROM lux_listings_src_26000.valid_from) AS window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_from) AS window_start__extract_doy + , lux_listings_src_26000.valid_to AS window_end__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_to) AS window_end__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_to) AS window_end__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_to) AS window_end__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_to) AS window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS window_end__extract_day + , EXTRACT(isodow FROM lux_listings_src_26000.valid_to) AS window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_to) AS window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux + , lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_from) AS lux_listing__window_start__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_from) AS lux_listing__window_start__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_from) AS lux_listing__window_start__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_from) AS lux_listing__window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_day + , EXTRACT(isodow FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_doy + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_to) AS lux_listing__window_end__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_to) AS lux_listing__window_end__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_to) AS lux_listing__window_end__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_to) AS lux_listing__window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_day + , EXTRACT(isodow FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + , lux_listings_src_26000.lux_listing_id AS lux_listing + FROM ***************************.dim_lux_listings lux_listings_src_26000 + ) subq_9 + ) subq_10 ON - subq_3.lux_listing = subq_5.lux_listing - ) subq_6 - ) subq_7 + subq_8.lux_listing = subq_10.lux_listing + ) subq_11 + ) subq_12 ON ( - subq_2.listing = subq_7.listing + subq_7.listing = subq_12.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.lux_listing__window_start__day + subq_7.metric_time__day >= subq_12.lux_listing__window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.lux_listing__window_end__day + subq_7.metric_time__day < subq_12.lux_listing__window_end__day ) OR ( - subq_7.lux_listing__window_end__day IS NULL + subq_12.lux_listing__window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_13 + ) subq_14 GROUP BY - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux -) subq_10 + subq_14.metric_time__day + , subq_14.listing__lux_listing__is_confirmed_lux +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0_optimized.sql index 0ef5f08ffa..eb9b15d13c 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , SUM(subq_13.bookings) AS bookings + subq_18.metric_time__day AS metric_time__day + , subq_23.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_18.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,35 +15,35 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_18 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , lux_listing_mapping_src_26003.listing_id AS listing - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 + lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , lux_listing_mapping_src_26000.listing_id AS listing + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 LEFT OUTER JOIN - ***************************.dim_lux_listings lux_listings_src_26004 + ***************************.dim_lux_listings lux_listings_src_26000 ON - lux_listing_mapping_src_26003.lux_listing_id = lux_listings_src_26004.lux_listing_id -) subq_18 + lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id +) subq_23 ON ( - subq_13.listing = subq_18.listing + subq_18.listing = subq_23.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.lux_listing__window_start__day + subq_18.metric_time__day >= subq_23.lux_listing__window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.lux_listing__window_end__day + subq_18.metric_time__day < subq_23.lux_listing__window_end__day ) OR ( - subq_18.lux_listing__window_end__day IS NULL + subq_23.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.lux_listing__is_confirmed_lux + subq_18.metric_time__day + , subq_23.lux_listing__is_confirmed_lux diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0.sql index ebedc871a4..434656619b 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0.sql @@ -1,93 +1,93 @@ -- Compute Metrics via Expressions SELECT - subq_10.account_id__customer_id__customer_name - , subq_10.txn_count + subq_14.account_id__customer_id__customer_name + , subq_14.txn_count FROM ( -- Aggregate Measures SELECT - subq_9.account_id__customer_id__customer_name - , SUM(subq_9.txn_count) AS txn_count + subq_13.account_id__customer_id__customer_name + , SUM(subq_13.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_8.account_id__customer_id__customer_name - , subq_8.txn_count + subq_12.account_id__customer_id__customer_name + , subq_12.txn_count FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_2.account_id AS account_id - , subq_7.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_2.txn_count AS txn_count + subq_6.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_6.account_id AS account_id + , subq_11.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_6.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_1.ds_partitioned__day - , subq_1.account_id - , subq_1.txn_count + subq_5.ds_partitioned__day + , subq_5.account_id + , subq_5.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.account_id__ds_partitioned__day - , subq_0.account_id__ds_partitioned__week - , subq_0.account_id__ds_partitioned__month - , subq_0.account_id__ds_partitioned__quarter - , subq_0.account_id__ds_partitioned__year - , subq_0.account_id__ds_partitioned__extract_year - , subq_0.account_id__ds_partitioned__extract_quarter - , subq_0.account_id__ds_partitioned__extract_month - , subq_0.account_id__ds_partitioned__extract_day - , subq_0.account_id__ds_partitioned__extract_dow - , subq_0.account_id__ds_partitioned__extract_doy - , subq_0.account_id__ds__day - , subq_0.account_id__ds__week - , subq_0.account_id__ds__month - , subq_0.account_id__ds__quarter - , subq_0.account_id__ds__year - , subq_0.account_id__ds__extract_year - , subq_0.account_id__ds__extract_quarter - , subq_0.account_id__ds__extract_month - , subq_0.account_id__ds__extract_day - , subq_0.account_id__ds__extract_dow - , subq_0.account_id__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.account_id - , subq_0.account_month - , subq_0.account_id__account_month - , subq_0.txn_count + subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.account_id__ds_partitioned__day + , subq_4.account_id__ds_partitioned__week + , subq_4.account_id__ds_partitioned__month + , subq_4.account_id__ds_partitioned__quarter + , subq_4.account_id__ds_partitioned__year + , subq_4.account_id__ds_partitioned__extract_year + , subq_4.account_id__ds_partitioned__extract_quarter + , subq_4.account_id__ds_partitioned__extract_month + , subq_4.account_id__ds_partitioned__extract_day + , subq_4.account_id__ds_partitioned__extract_dow + , subq_4.account_id__ds_partitioned__extract_doy + , subq_4.account_id__ds__day + , subq_4.account_id__ds__week + , subq_4.account_id__ds__month + , subq_4.account_id__ds__quarter + , subq_4.account_id__ds__year + , subq_4.account_id__ds__extract_year + , subq_4.account_id__ds__extract_quarter + , subq_4.account_id__ds__extract_month + , subq_4.account_id__ds__extract_day + , subq_4.account_id__ds__extract_dow + , subq_4.account_id__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.account_id + , subq_4.account_month + , subq_4.account_id__account_month + , subq_4.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -140,118 +140,118 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_4 + ) subq_5 + ) subq_6 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_6.ds_partitioned__day - , subq_6.account_id - , subq_6.customer_id__customer_name + subq_10.ds_partitioned__day + , subq_10.account_id + , subq_10.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_3.ds_partitioned__day AS ds_partitioned__day - , subq_3.ds_partitioned__week AS ds_partitioned__week - , subq_3.ds_partitioned__month AS ds_partitioned__month - , subq_3.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_3.ds_partitioned__year AS ds_partitioned__year - , subq_3.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_3.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_3.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_3.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_3.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_3.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_3.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_3.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_3.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_3.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_3.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_3.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_3.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_5.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_5.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_5.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_5.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_5.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_5.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_3.account_id AS account_id - , subq_3.customer_id AS customer_id - , subq_3.account_id__customer_id AS account_id__customer_id - , subq_3.bridge_account__account_id AS bridge_account__account_id - , subq_3.bridge_account__customer_id AS bridge_account__customer_id - , subq_3.extra_dim AS extra_dim - , subq_3.account_id__extra_dim AS account_id__extra_dim - , subq_3.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_5.customer_name AS customer_id__customer_name - , subq_5.customer_atomic_weight AS customer_id__customer_atomic_weight + subq_7.ds_partitioned__day AS ds_partitioned__day + , subq_7.ds_partitioned__week AS ds_partitioned__week + , subq_7.ds_partitioned__month AS ds_partitioned__month + , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_7.ds_partitioned__year AS ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_9.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_9.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_9.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_9.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_9.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_9.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_7.account_id AS account_id + , subq_7.customer_id AS customer_id + , subq_7.account_id__customer_id AS account_id__customer_id + , subq_7.bridge_account__account_id AS bridge_account__account_id + , subq_7.bridge_account__customer_id AS bridge_account__customer_id + , subq_7.extra_dim AS extra_dim + , subq_7.account_id__extra_dim AS account_id__extra_dim + , subq_7.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_9.customer_name AS customer_id__customer_name + , subq_9.customer_atomic_weight AS customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT - bridge_table_src_22001.extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS account_id__extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(isodow FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS bridge_account__extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_day - , EXTRACT(isodow FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy - , bridge_table_src_22001.account_id - , bridge_table_src_22001.customer_id - , bridge_table_src_22001.customer_id AS account_id__customer_id - , bridge_table_src_22001.account_id AS bridge_account__account_id - , bridge_table_src_22001.customer_id AS bridge_account__customer_id - FROM ***************************.bridge_table bridge_table_src_22001 - ) subq_3 + bridge_table_src_22000.extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS account_id__extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(isodow FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS bridge_account__extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_day + , EXTRACT(isodow FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy + , bridge_table_src_22000.account_id + , bridge_table_src_22000.customer_id + , bridge_table_src_22000.customer_id AS account_id__customer_id + , bridge_table_src_22000.account_id AS bridge_account__account_id + , bridge_table_src_22000.customer_id AS bridge_account__customer_id + FROM ***************************.bridge_table bridge_table_src_22000 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -283,82 +283,82 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.customer_id__ds_partitioned__day - , subq_4.customer_id__ds_partitioned__week - , subq_4.customer_id__ds_partitioned__month - , subq_4.customer_id__ds_partitioned__quarter - , subq_4.customer_id__ds_partitioned__year - , subq_4.customer_id__ds_partitioned__extract_year - , subq_4.customer_id__ds_partitioned__extract_quarter - , subq_4.customer_id__ds_partitioned__extract_month - , subq_4.customer_id__ds_partitioned__extract_day - , subq_4.customer_id__ds_partitioned__extract_dow - , subq_4.customer_id__ds_partitioned__extract_doy - , subq_4.customer_id - , subq_4.customer_name - , subq_4.customer_atomic_weight - , subq_4.customer_id__customer_name - , subq_4.customer_id__customer_atomic_weight + subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.customer_id__ds_partitioned__day + , subq_8.customer_id__ds_partitioned__week + , subq_8.customer_id__ds_partitioned__month + , subq_8.customer_id__ds_partitioned__quarter + , subq_8.customer_id__ds_partitioned__year + , subq_8.customer_id__ds_partitioned__extract_year + , subq_8.customer_id__ds_partitioned__extract_quarter + , subq_8.customer_id__ds_partitioned__extract_month + , subq_8.customer_id__ds_partitioned__extract_day + , subq_8.customer_id__ds_partitioned__extract_dow + , subq_8.customer_id__ds_partitioned__extract_doy + , subq_8.customer_id + , subq_8.customer_name + , subq_8.customer_atomic_weight + , subq_8.customer_id__customer_name + , subq_8.customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT - customer_table_src_22003.customer_name - , customer_table_src_22003.customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_22003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_22003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_22003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_22003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_doy - , customer_table_src_22003.customer_name AS customer_id__customer_name - , customer_table_src_22003.customer_atomic_weight AS customer_id__customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_day - , EXTRACT(isodow FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_doy - , customer_table_src_22003.customer_id - FROM ***************************.customer_table customer_table_src_22003 - ) subq_4 - ) subq_5 + customer_table_src_22000.customer_name + , customer_table_src_22000.customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , customer_table_src_22000.customer_name AS customer_id__customer_name + , customer_table_src_22000.customer_atomic_weight AS customer_id__customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_day + , EXTRACT(isodow FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy + , customer_table_src_22000.customer_id + FROM ***************************.customer_table customer_table_src_22000 + ) subq_8 + ) subq_9 ON ( - subq_3.customer_id = subq_5.customer_id + subq_7.customer_id = subq_9.customer_id ) AND ( - subq_3.ds_partitioned__day = subq_5.ds_partitioned__day + subq_7.ds_partitioned__day = subq_9.ds_partitioned__day ) - ) subq_6 - ) subq_7 + ) subq_10 + ) subq_11 ON ( - subq_2.account_id = subq_7.account_id + subq_6.account_id = subq_11.account_id ) AND ( - subq_2.ds_partitioned__day = subq_7.ds_partitioned__day + subq_6.ds_partitioned__day = subq_11.ds_partitioned__day ) - ) subq_8 - ) subq_9 + ) subq_12 + ) subq_13 GROUP BY - subq_9.account_id__customer_id__customer_name -) subq_10 + subq_13.account_id__customer_id__customer_name +) subq_14 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0_optimized.sql index 7802d2f867..13473156ca 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0_optimized.sql @@ -3,31 +3,31 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_18.customer_id__customer_name AS account_id__customer_id__customer_name + subq_22.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__day - , bridge_table_src_22001.account_id AS account_id - , customer_table_src_22003.customer_name AS customer_id__customer_name - FROM ***************************.bridge_table bridge_table_src_22001 + DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__day + , bridge_table_src_22000.account_id AS account_id + , customer_table_src_22000.customer_name AS customer_id__customer_name + FROM ***************************.bridge_table bridge_table_src_22000 LEFT OUTER JOIN - ***************************.customer_table customer_table_src_22003 + ***************************.customer_table customer_table_src_22000 ON ( - bridge_table_src_22001.customer_id = customer_table_src_22003.customer_id + bridge_table_src_22000.customer_id = customer_table_src_22000.customer_id ) AND ( - DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) + DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_18 +) subq_22 ON ( - account_month_txns_src_22000.account_id = subq_18.account_id + account_month_txns_src_22000.account_id = subq_22.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day ) GROUP BY - subq_18.customer_id__customer_name + subq_22.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0.sql index 819dc05fc2..b420a6ff2b 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0.sql @@ -1,536 +1,536 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_5.bookings) AS bookings - , MAX(subq_11.listings) AS listings + MAX(subq_18.bookings) AS bookings + , MAX(subq_24.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_4.bookings + subq_17.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_3.bookings) AS bookings + SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_2.bookings + subq_15.bookings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.ds_partitioned__day - , subq_1.ds_partitioned__week - , subq_1.ds_partitioned__month - , subq_1.ds_partitioned__quarter - , subq_1.ds_partitioned__year - , subq_1.ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy - , subq_1.paid_at__day - , subq_1.paid_at__week - , subq_1.paid_at__month - , subq_1.paid_at__quarter - , subq_1.paid_at__year - , subq_1.paid_at__extract_year - , subq_1.paid_at__extract_quarter - , subq_1.paid_at__extract_month - , subq_1.paid_at__extract_day - , subq_1.paid_at__extract_dow - , subq_1.paid_at__extract_doy - , subq_1.booking__ds__day - , subq_1.booking__ds__week - , subq_1.booking__ds__month - , subq_1.booking__ds__quarter - , subq_1.booking__ds__year - , subq_1.booking__ds__extract_year - , subq_1.booking__ds__extract_quarter - , subq_1.booking__ds__extract_month - , subq_1.booking__ds__extract_day - , subq_1.booking__ds__extract_dow - , subq_1.booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day - , subq_1.booking__paid_at__week - , subq_1.booking__paid_at__month - , subq_1.booking__paid_at__quarter - , subq_1.booking__paid_at__year - , subq_1.booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.listing - , subq_1.guest - , subq_1.host - , subq_1.booking__listing - , subq_1.booking__guest - , subq_1.booking__host - , subq_1.is_instant - , subq_1.booking__is_instant - , subq_1.bookings - , subq_1.instant_bookings - , subq_1.booking_value - , subq_1.max_booking_value - , subq_1.min_booking_value - , subq_1.bookers - , subq_1.average_booking_value - , subq_1.referred_bookings - , subq_1.median_booking_value - , subq_1.booking_value_p99 - , subq_1.discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 + subq_14.ds__day + , subq_14.ds__week + , subq_14.ds__month + , subq_14.ds__quarter + , subq_14.ds__year + , subq_14.ds__extract_year + , subq_14.ds__extract_quarter + , subq_14.ds__extract_month + , subq_14.ds__extract_day + , subq_14.ds__extract_dow + , subq_14.ds__extract_doy + , subq_14.ds_partitioned__day + , subq_14.ds_partitioned__week + , subq_14.ds_partitioned__month + , subq_14.ds_partitioned__quarter + , subq_14.ds_partitioned__year + , subq_14.ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy + , subq_14.paid_at__day + , subq_14.paid_at__week + , subq_14.paid_at__month + , subq_14.paid_at__quarter + , subq_14.paid_at__year + , subq_14.paid_at__extract_year + , subq_14.paid_at__extract_quarter + , subq_14.paid_at__extract_month + , subq_14.paid_at__extract_day + , subq_14.paid_at__extract_dow + , subq_14.paid_at__extract_doy + , subq_14.booking__ds__day + , subq_14.booking__ds__week + , subq_14.booking__ds__month + , subq_14.booking__ds__quarter + , subq_14.booking__ds__year + , subq_14.booking__ds__extract_year + , subq_14.booking__ds__extract_quarter + , subq_14.booking__ds__extract_month + , subq_14.booking__ds__extract_day + , subq_14.booking__ds__extract_dow + , subq_14.booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day + , subq_14.booking__paid_at__week + , subq_14.booking__paid_at__month + , subq_14.booking__paid_at__quarter + , subq_14.booking__paid_at__year + , subq_14.booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy + , subq_14.metric_time__day + , subq_14.metric_time__week + , subq_14.metric_time__month + , subq_14.metric_time__quarter + , subq_14.metric_time__year + , subq_14.metric_time__extract_year + , subq_14.metric_time__extract_quarter + , subq_14.metric_time__extract_month + , subq_14.metric_time__extract_day + , subq_14.metric_time__extract_dow + , subq_14.metric_time__extract_doy + , subq_14.listing + , subq_14.guest + , subq_14.host + , subq_14.booking__listing + , subq_14.booking__guest + , subq_14.booking__host + , subq_14.is_instant + , subq_14.booking__is_instant + , subq_14.bookings + , subq_14.instant_bookings + , subq_14.booking_value + , subq_14.max_booking_value + , subq_14.min_booking_value + , subq_14.bookers + , subq_14.average_booking_value + , subq_14.referred_bookings + , subq_14.median_booking_value + , subq_14.booking_value_p99 + , subq_14.discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_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 + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.max_booking_value + , subq_13.min_booking_value + , subq_13.bookers + , subq_13.average_booking_value + , subq_13.referred_bookings + , subq_13.median_booking_value + , subq_13.booking_value_p99 + , subq_13.discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_2 - ) subq_3 - ) subq_4 -) subq_5 + , 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_13 + ) subq_14 + WHERE subq_14.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_15 + ) subq_16 + ) subq_17 +) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.listings + subq_23.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_9.listings) AS listings + SUM(subq_22.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_8.listings + subq_21.listings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] 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.created_at__day - , subq_7.created_at__week - , subq_7.created_at__month - , subq_7.created_at__quarter - , subq_7.created_at__year - , subq_7.created_at__extract_year - , subq_7.created_at__extract_quarter - , subq_7.created_at__extract_month - , subq_7.created_at__extract_day - , subq_7.created_at__extract_dow - , subq_7.created_at__extract_doy - , subq_7.listing__ds__day - , subq_7.listing__ds__week - , subq_7.listing__ds__month - , subq_7.listing__ds__quarter - , subq_7.listing__ds__year - , subq_7.listing__ds__extract_year - , subq_7.listing__ds__extract_quarter - , subq_7.listing__ds__extract_month - , subq_7.listing__ds__extract_day - , subq_7.listing__ds__extract_dow - , subq_7.listing__ds__extract_doy - , subq_7.listing__created_at__day - , subq_7.listing__created_at__week - , subq_7.listing__created_at__month - , subq_7.listing__created_at__quarter - , subq_7.listing__created_at__year - , subq_7.listing__created_at__extract_year - , subq_7.listing__created_at__extract_quarter - , subq_7.listing__created_at__extract_month - , subq_7.listing__created_at__extract_day - , subq_7.listing__created_at__extract_dow - , subq_7.listing__created_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.user - , subq_7.listing__user - , subq_7.country_latest - , subq_7.is_lux_latest - , subq_7.capacity_latest - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.listings - , subq_7.largest_listing - , subq_7.smallest_listing + 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.created_at__day + , subq_20.created_at__week + , subq_20.created_at__month + , subq_20.created_at__quarter + , subq_20.created_at__year + , subq_20.created_at__extract_year + , subq_20.created_at__extract_quarter + , subq_20.created_at__extract_month + , subq_20.created_at__extract_day + , subq_20.created_at__extract_dow + , subq_20.created_at__extract_doy + , subq_20.listing__ds__day + , subq_20.listing__ds__week + , subq_20.listing__ds__month + , subq_20.listing__ds__quarter + , subq_20.listing__ds__year + , subq_20.listing__ds__extract_year + , subq_20.listing__ds__extract_quarter + , subq_20.listing__ds__extract_month + , subq_20.listing__ds__extract_day + , subq_20.listing__ds__extract_dow + , subq_20.listing__ds__extract_doy + , subq_20.listing__created_at__day + , subq_20.listing__created_at__week + , subq_20.listing__created_at__month + , subq_20.listing__created_at__quarter + , subq_20.listing__created_at__year + , subq_20.listing__created_at__extract_year + , subq_20.listing__created_at__extract_quarter + , subq_20.listing__created_at__extract_month + , subq_20.listing__created_at__extract_day + , subq_20.listing__created_at__extract_dow + , subq_20.listing__created_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.user + , subq_20.listing__user + , subq_20.country_latest + , subq_20.is_lux_latest + , subq_20.capacity_latest + , subq_20.listing__country_latest + , subq_20.listing__is_lux_latest + , subq_20.listing__capacity_latest + , subq_20.listings + , subq_20.largest_listing + , subq_20.smallest_listing FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_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.created_at__day + , subq_19.created_at__week + , subq_19.created_at__month + , subq_19.created_at__quarter + , subq_19.created_at__year + , subq_19.created_at__extract_year + , subq_19.created_at__extract_quarter + , subq_19.created_at__extract_month + , subq_19.created_at__extract_day + , subq_19.created_at__extract_dow + , subq_19.created_at__extract_doy + , subq_19.listing__ds__day + , subq_19.listing__ds__week + , subq_19.listing__ds__month + , subq_19.listing__ds__quarter + , subq_19.listing__ds__year + , subq_19.listing__ds__extract_year + , subq_19.listing__ds__extract_quarter + , subq_19.listing__ds__extract_month + , subq_19.listing__ds__extract_day + , subq_19.listing__ds__extract_dow + , subq_19.listing__ds__extract_doy + , subq_19.listing__created_at__day + , subq_19.listing__created_at__week + , subq_19.listing__created_at__month + , subq_19.listing__created_at__quarter + , subq_19.listing__created_at__year + , subq_19.listing__created_at__extract_year + , subq_19.listing__created_at__extract_quarter + , subq_19.listing__created_at__extract_month + , subq_19.listing__created_at__extract_day + , subq_19.listing__created_at__extract_dow + , subq_19.listing__created_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.user + , subq_19.listing__user + , subq_19.country_latest + , subq_19.is_lux_latest + , subq_19.capacity_latest + , subq_19.listing__country_latest + , subq_19.listing__is_lux_latest + , subq_19.listing__capacity_latest + , subq_19.listings + , subq_19.largest_listing + , subq_19.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_6 - ) subq_7 - WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_8 - ) subq_9 - ) subq_10 -) subq_11 + , 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_19 + ) subq_20 + WHERE subq_20.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_21 + ) subq_22 + ) subq_23 +) subq_24 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 2691ca3c38..71a7d98121 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_17.bookings) AS bookings - , MAX(subq_23.listings) AS listings + MAX(subq_30.bookings) AS bookings + , MAX(subq_36.listings) AS listings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -11,9 +11,9 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_17 +) subq_30 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -23,6 +23,6 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_23 +) subq_36 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql index f8e4a004b6..8749965e29 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql @@ -1,241 +1,241 @@ -- Compute Metrics via Expressions SELECT - subq_7.user__home_state - , subq_7.identity_verifications + subq_16.user__home_state + , subq_16.identity_verifications FROM ( -- Aggregate Measures SELECT - subq_6.user__home_state - , SUM(subq_6.identity_verifications) AS identity_verifications + subq_15.user__home_state + , SUM(subq_15.identity_verifications) AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'user__home_state'] SELECT - subq_5.user__home_state - , subq_5.identity_verifications + subq_14.user__home_state + , subq_14.identity_verifications FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__day AS user__ds_partitioned__day - , subq_2.user AS user - , subq_4.home_state AS user__home_state - , subq_2.identity_verifications AS identity_verifications + subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__day AS user__ds_partitioned__day + , subq_11.user AS user + , subq_13.home_state AS user__home_state + , subq_11.identity_verifications AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT - subq_1.ds_partitioned__day - , subq_1.user - , subq_1.identity_verifications + subq_10.ds_partitioned__day + , subq_10.user + , subq_10.identity_verifications 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.verification__ds__day - , subq_0.verification__ds__week - , subq_0.verification__ds__month - , subq_0.verification__ds__quarter - , subq_0.verification__ds__year - , subq_0.verification__ds__extract_year - , subq_0.verification__ds__extract_quarter - , subq_0.verification__ds__extract_month - , subq_0.verification__ds__extract_day - , subq_0.verification__ds__extract_dow - , subq_0.verification__ds__extract_doy - , subq_0.verification__ds_partitioned__day - , subq_0.verification__ds_partitioned__week - , subq_0.verification__ds_partitioned__month - , subq_0.verification__ds_partitioned__quarter - , subq_0.verification__ds_partitioned__year - , subq_0.verification__ds_partitioned__extract_year - , subq_0.verification__ds_partitioned__extract_quarter - , subq_0.verification__ds_partitioned__extract_month - , subq_0.verification__ds_partitioned__extract_day - , subq_0.verification__ds_partitioned__extract_dow - , subq_0.verification__ds_partitioned__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.verification - , subq_0.user - , subq_0.verification__user - , subq_0.verification_type - , subq_0.verification__verification_type - , subq_0.identity_verifications + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.verification__ds__day + , subq_9.verification__ds__week + , subq_9.verification__ds__month + , subq_9.verification__ds__quarter + , subq_9.verification__ds__year + , subq_9.verification__ds__extract_year + , subq_9.verification__ds__extract_quarter + , subq_9.verification__ds__extract_month + , subq_9.verification__ds__extract_day + , subq_9.verification__ds__extract_dow + , subq_9.verification__ds__extract_doy + , subq_9.verification__ds_partitioned__day + , subq_9.verification__ds_partitioned__week + , subq_9.verification__ds_partitioned__month + , subq_9.verification__ds_partitioned__quarter + , subq_9.verification__ds_partitioned__year + , subq_9.verification__ds_partitioned__extract_year + , subq_9.verification__ds_partitioned__extract_quarter + , subq_9.verification__ds_partitioned__extract_month + , subq_9.verification__ds_partitioned__extract_day + , subq_9.verification__ds_partitioned__extract_dow + , subq_9.verification__ds_partitioned__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.verification + , subq_9.user + , subq_9.verification__user + , subq_9.verification_type + , subq_9.verification__verification_type + , subq_9.identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user - FROM ***************************.fct_id_verifications id_verifications_src_28004 - ) subq_0 - ) subq_1 - ) subq_2 + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user + FROM ***************************.fct_id_verifications id_verifications_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state', 'ds_partitioned__day', 'user'] SELECT - subq_3.ds_partitioned__day - , subq_3.user - , subq_3.home_state + subq_12.ds_partitioned__day + , subq_12.user + , subq_12.home_state FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - DATE_TRUNC('day', users_ds_source_src_28008.ds) AS ds__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds) AS ds__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds) AS ds__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds) AS ds__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds) AS ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS ds__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28008.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds) AS ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.created_at) AS created_at__day - , DATE_TRUNC('week', users_ds_source_src_28008.created_at) AS created_at__week - , DATE_TRUNC('month', users_ds_source_src_28008.created_at) AS created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.created_at) AS created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.created_at) AS created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28008.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.created_at) AS created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state - , DATE_TRUNC('day', users_ds_source_src_28008.ds) AS user__ds__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds) AS user__ds__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds) AS user__ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS user__ds__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28008.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds) AS user__ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.created_at) AS user__created_at__day - , DATE_TRUNC('week', users_ds_source_src_28008.created_at) AS user__created_at__week - , DATE_TRUNC('month', users_ds_source_src_28008.created_at) AS user__created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.created_at) AS user__created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.created_at) AS user__created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state AS user__home_state - , users_ds_source_src_28008.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28008 - ) subq_3 - ) subq_4 + DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_12 + ) subq_13 ON ( - subq_2.user = subq_4.user + subq_11.user = subq_13.user ) AND ( - subq_2.ds_partitioned__day = subq_4.ds_partitioned__day + subq_11.ds_partitioned__day = subq_13.ds_partitioned__day ) - ) subq_5 - ) subq_6 + ) subq_14 + ) subq_15 GROUP BY - subq_6.user__home_state -) subq_7 + subq_15.user__home_state +) subq_16 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0_optimized.sql index 9f15f9bb3d..54ea641813 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0_optimized.sql @@ -3,8 +3,8 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - users_ds_source_src_28008.home_state AS user__home_state - , SUM(subq_10.identity_verifications) AS identity_verifications + users_ds_source_src_28000.home_state AS user__home_state + , SUM(subq_19.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' -- Metric Time Dimension 'ds' @@ -13,15 +13,15 @@ FROM ( DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications - FROM ***************************.fct_id_verifications id_verifications_src_28004 -) subq_10 + FROM ***************************.fct_id_verifications id_verifications_src_28000 +) subq_19 LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_28008 + ***************************.dim_users users_ds_source_src_28000 ON ( - subq_10.user = users_ds_source_src_28008.user_id + subq_19.user = users_ds_source_src_28000.user_id ) AND ( - subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) + subq_19.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) ) GROUP BY - users_ds_source_src_28008.home_state + users_ds_source_src_28000.home_state diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0.sql index 4075567205..f5fb45927e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0.sql @@ -1,439 +1,439 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_value) AS booking_value + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 -) subq_4 + subq_11.metric_time__day + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_value) AS booking_value + subq_16.metric_time__day + , SUM(subq_16.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_value + subq_15.metric_time__day + , subq_15.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_16.metric_time__day + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0_optimized.sql index ccc0d8cd89..7831d40fe6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql index a1d54bfa48..cd3d4c172a 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql @@ -68,62 +68,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0_optimized.sql index 22b719da85..1653ada5bd 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_3 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql index fce16f303c..5ce3103dde 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -1,383 +1,383 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_19.booking__is_instant + , subq_19.bookings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_18.booking__is_instant + , SUM(subq_18.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_17.booking__is_instant + , subq_17.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_16.booking__is_instant + , subq_16.listing__country_latest + , subq_16.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.booking__is_instant + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.listing + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__country_latest = 'us' - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_18.booking__is_instant +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index fdbb61ce0e..433c9799b5 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.country AS listing__country_latest - , subq_13.bookings AS bookings + subq_22.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.country AS listing__country_latest + , subq_22.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -20,13 +20,13 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28005.listing_id -) subq_18 + subq_22.listing = listings_latest_src_28000.listing_id +) subq_27 WHERE listing__country_latest = 'us' GROUP BY booking__is_instant diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql index 96c20638a0..33edfd74b6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql @@ -1,139 +1,139 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS family_bookings + subq_11.metric_time__day + , subq_11.bookings AS family_bookings FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_10.metric_time__day + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.listing__capacity - , subq_6.bookings + subq_8.metric_time__day + , subq_8.listing__capacity + , subq_8.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.listing__capacity - , subq_5.bookings + subq_7.metric_time__day + , subq_7.listing__capacity + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_4.window_start__day AS listing__window_start__day - , subq_4.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_4.capacity AS listing__capacity - , subq_2.bookings AS bookings + subq_4.metric_time__day AS metric_time__day + , subq_6.window_start__day AS listing__window_start__day + , subq_6.window_end__day AS listing__window_end__day + , subq_4.listing AS listing + , subq_6.capacity AS listing__capacity + , subq_4.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_3.metric_time__day + , subq_3.listing + , subq_3.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + 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.user + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.booking__user + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.bookers + , subq_2.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -220,94 +220,94 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_2 + ) subq_3 + ) subq_4 LEFT OUTER JOIN ( -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_3.window_start__day - , subq_3.window_end__day - , subq_3.listing - , subq_3.capacity + subq_5.window_start__day + , subq_5.window_end__day + , subq_5.listing + , subq_5.capacity FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 - ) subq_4 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_4.listing + subq_4.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_4.window_start__day + subq_4.metric_time__day >= subq_6.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_4.window_end__day + subq_4.metric_time__day < subq_6.window_end__day ) OR ( - subq_4.window_end__day IS NULL + subq_6.window_end__day IS NULL ) ) ) - ) subq_5 - ) subq_6 + ) subq_7 + ) subq_8 WHERE listing__capacity > 2 - ) subq_7 - ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_8.metric_time__day -) subq_9 + subq_10.metric_time__day +) subq_11 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql index fc848091b1..0f3bd95cd6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_12.metric_time__day AS metric_time__day - , listings_src_26002.capacity AS listing__capacity - , subq_12.bookings AS bookings + subq_14.metric_time__day AS metric_time__day + , listings_src_26000.capacity AS listing__capacity + , subq_14.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -21,24 +21,24 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_12 + ) subq_14 LEFT OUTER JOIN - ***************************.dim_listings listings_src_26002 + ***************************.dim_listings listings_src_26000 ON ( - subq_12.listing = listings_src_26002.listing_id + subq_14.listing = listings_src_26000.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_26002.active_from + subq_14.metric_time__day >= listings_src_26000.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_26002.active_to + subq_14.metric_time__day < listings_src_26000.active_to ) OR ( - listings_src_26002.active_to IS NULL + listings_src_26000.active_to IS NULL ) ) ) -) subq_16 +) subq_18 WHERE listing__capacity > 2 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_limit_rows__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_limit_rows__plan0.sql index f70d1c6eae..0cc25cd1eb 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_limit_rows__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_limit_rows__plan0.sql @@ -1,220 +1,220 @@ -- Order By [] Limit 1 SELECT - subq_4.ds__day - , subq_4.bookings + subq_13.ds__day + , subq_13.bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.bookings + subq_12.ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.bookings + subq_10.ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__day - ) subq_3 -) subq_4 + subq_11.ds__day + ) subq_12 +) subq_13 LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_limit_rows__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_limit_rows__plan0_optimized.sql index a71f7ae0e8..0780ad9c07 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_limit_rows__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_limit_rows__plan0_optimized.sql @@ -11,8 +11,8 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_7 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_16 GROUP BY ds__day LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0.sql index a16164c267..c892fc3441 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0.sql @@ -1,150 +1,150 @@ -- Compute Metrics via Expressions SELECT - subq_3.listing__country_latest - , subq_3.listings + subq_12.listing__country_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_2.listing__country_latest - , SUM(subq_2.listings) AS listings + subq_11.listing__country_latest + , SUM(subq_11.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'listing__country_latest'] SELECT - subq_1.listing__country_latest - , subq_1.listings + subq_10.listing__country_latest + , subq_10.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.created_at__day - , subq_0.created_at__week - , subq_0.created_at__month - , subq_0.created_at__quarter - , subq_0.created_at__year - , subq_0.created_at__extract_year - , subq_0.created_at__extract_quarter - , subq_0.created_at__extract_month - , subq_0.created_at__extract_day - , subq_0.created_at__extract_dow - , subq_0.created_at__extract_doy - , subq_0.listing__ds__day - , subq_0.listing__ds__week - , subq_0.listing__ds__month - , subq_0.listing__ds__quarter - , subq_0.listing__ds__year - , subq_0.listing__ds__extract_year - , subq_0.listing__ds__extract_quarter - , subq_0.listing__ds__extract_month - , subq_0.listing__ds__extract_day - , subq_0.listing__ds__extract_dow - , subq_0.listing__ds__extract_doy - , subq_0.listing__created_at__day - , subq_0.listing__created_at__week - , subq_0.listing__created_at__month - , subq_0.listing__created_at__quarter - , subq_0.listing__created_at__year - , subq_0.listing__created_at__extract_year - , subq_0.listing__created_at__extract_quarter - , subq_0.listing__created_at__extract_month - , subq_0.listing__created_at__extract_day - , subq_0.listing__created_at__extract_dow - , subq_0.listing__created_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.user - , subq_0.listing__user - , subq_0.country_latest - , subq_0.is_lux_latest - , subq_0.capacity_latest - , subq_0.listing__country_latest - , subq_0.listing__is_lux_latest - , subq_0.listing__capacity_latest - , subq_0.listings - , subq_0.largest_listing - , subq_0.smallest_listing + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.listing__country_latest -) subq_3 + subq_11.listing__country_latest +) subq_12 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0_optimized.sql index 8486e86449..c0733d39a6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT country AS listing__country_latest , 1 AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_6 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_15 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql index 5564f9e3a9..a3fa71afd3 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql @@ -1,1003 +1,1003 @@ -- Compute Metrics via Expressions SELECT - subq_29.metric_time__day + subq_38.metric_time__day , average_booking_value * bookings / NULLIF(booking_value, 0) AS lux_booking_value_rate_expr FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_28.booking_value) AS booking_value + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_37.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_19.metric_time__day + , subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , AVG(subq_9.average_booking_value) AS average_booking_value + subq_18.metric_time__day + , AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_17.metric_time__day + , subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.metric_time__day + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.metric_time__day + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.average_booking_value AS average_booking_value + subq_11.metric_time__day AS metric_time__day + , subq_11.listing AS listing + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.average_booking_value + subq_10.metric_time__day + , subq_10.listing + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_18.metric_time__day + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day - , subq_22.bookings + subq_31.metric_time__day + , subq_31.bookings FROM ( -- Aggregate Measures SELECT - subq_21.metric_time__day - , SUM(subq_21.bookings) AS bookings + subq_30.metric_time__day + , SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.metric_time__day + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.metric_time__day + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.metric_time__day AS metric_time__day + , subq_23.listing AS listing + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.bookings + subq_22.metric_time__day + , subq_22.listing + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE listing__is_lux_latest - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 GROUP BY - subq_21.metric_time__day - ) subq_22 - ) subq_23 + subq_30.metric_time__day + ) subq_31 + ) subq_32 ON - subq_11.metric_time__day = subq_23.metric_time__day + subq_20.metric_time__day = subq_32.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.booking_value + subq_36.metric_time__day + , subq_36.booking_value FROM ( -- Aggregate Measures SELECT - subq_26.metric_time__day - , SUM(subq_26.booking_value) AS booking_value + subq_35.metric_time__day + , SUM(subq_35.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_25.metric_time__day - , subq_25.booking_value + subq_34.metric_time__day + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 GROUP BY - subq_26.metric_time__day - ) subq_27 - ) subq_28 + subq_35.metric_time__day + ) subq_36 + ) subq_37 ON - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day) = subq_37.metric_time__day GROUP BY - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) -) subq_29 + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day, subq_37.metric_time__day) +) subq_38 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql index 69ba3892a2..91ab825138 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) AS metric_time__day - , MAX(subq_41.average_booking_value) AS average_booking_value - , MAX(subq_53.bookings) AS bookings - , MAX(subq_58.booking_value) AS booking_value + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day, subq_67.metric_time__day) AS metric_time__day + , MAX(subq_50.average_booking_value) AS average_booking_value + , MAX(subq_62.bookings) AS bookings + , MAX(subq_67.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -21,19 +21,19 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - DATE_TRUNC('day', bookings_source_src_28001.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + DATE_TRUNC('day', bookings_source_src_28000.ds) AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_37 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_46 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_41 + ) subq_50 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -46,9 +46,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_44.metric_time__day AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_44.bookings AS bookings + subq_53.metric_time__day AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_53.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -57,19 +57,19 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_44 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_53 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_44.listing = listings_latest_src_28005.listing_id - ) subq_49 + subq_53.listing = listings_latest_src_28000.listing_id + ) subq_58 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_53 + ) subq_62 ON - subq_41.metric_time__day = subq_53.metric_time__day + subq_50.metric_time__day = subq_62.metric_time__day FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -79,12 +79,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_58 + ) subq_67 ON - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day) = subq_58.metric_time__day + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day) = subq_67.metric_time__day GROUP BY - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) -) subq_59 + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day, subq_67.metric_time__day) +) subq_68 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql index 076627353a..e2faf479b9 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,460 +1,460 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , CAST(subq_12.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_12.booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio + subq_21.metric_time__day + , CAST(subq_21.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_21.booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , MAX(subq_6.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_11.booking_value) AS booking_value + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day + , MAX(subq_15.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_20.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.booking_value AS booking_value_with_is_instant_constraint + subq_14.metric_time__day + , subq_14.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.booking_value) AS booking_value + subq_13.metric_time__day + , SUM(subq_13.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.booking_value + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_13.metric_time__day + ) subq_14 + ) subq_15 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_19.metric_time__day + , subq_19.booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.booking_value) AS booking_value + subq_18.metric_time__day + , SUM(subq_18.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.ds_partitioned__day + , subq_16.ds_partitioned__week + , subq_16.ds_partitioned__month + , subq_16.ds_partitioned__quarter + , subq_16.ds_partitioned__year + , subq_16.ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy + , subq_16.paid_at__day + , subq_16.paid_at__week + , subq_16.paid_at__month + , subq_16.paid_at__quarter + , subq_16.paid_at__year + , subq_16.paid_at__extract_year + , subq_16.paid_at__extract_quarter + , subq_16.paid_at__extract_month + , subq_16.paid_at__extract_day + , subq_16.paid_at__extract_dow + , subq_16.paid_at__extract_doy + , subq_16.booking__ds__day + , subq_16.booking__ds__week + , subq_16.booking__ds__month + , subq_16.booking__ds__quarter + , subq_16.booking__ds__year + , subq_16.booking__ds__extract_year + , subq_16.booking__ds__extract_quarter + , subq_16.booking__ds__extract_month + , subq_16.booking__ds__extract_day + , subq_16.booking__ds__extract_dow + , subq_16.booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day + , subq_16.booking__paid_at__week + , subq_16.booking__paid_at__month + , subq_16.booking__paid_at__quarter + , subq_16.booking__paid_at__year + , subq_16.booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.listing + , subq_16.guest + , subq_16.host + , subq_16.booking__listing + , subq_16.booking__guest + , subq_16.booking__host + , subq_16.is_instant + , subq_16.booking__is_instant + , subq_16.bookings + , subq_16.instant_bookings + , subq_16.booking_value + , subq_16.max_booking_value + , subq_16.min_booking_value + , subq_16.bookers + , subq_16.average_booking_value + , subq_16.referred_bookings + , subq_16.median_booking_value + , subq_16.booking_value_p99 + , subq_16.discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 + , subq_16.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_7 - ) subq_8 - ) subq_9 + , 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_16 + ) subq_17 + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_18.metric_time__day + ) subq_19 + ) subq_20 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_15.metric_time__day = subq_20.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) +) subq_21 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql index bc8639fea2..d0df93a404 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/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_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , MAX(subq_19.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_24.booking_value) AS booking_value + COALESCE(subq_28.metric_time__day, subq_33.metric_time__day) AS metric_time__day + , MAX(subq_28.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_33.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_28 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -39,12 +39,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_33 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_28.metric_time__day = subq_33.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_28.metric_time__day, subq_33.metric_time__day) +) subq_34 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 5c2c621376..ea8c9d8383 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,234 +1,234 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day + subq_15.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.bookings AS delayed_bookings + subq_14.metric_time__day + , subq_14.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_13.metric_time__day + , SUM(subq_13.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE NOT booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY - subq_4.metric_time__day - ) subq_5 -) subq_6 + subq_13.metric_time__day + ) subq_14 +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index df414b0013..c494772d25 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -18,9 +18,9 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 4944ea2a89..ddfee701c3 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -1,366 +1,366 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_10.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_10.listings, 0) AS DOUBLE PRECISION) AS bookings_per_listing + CAST(subq_19.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_19.listings, 0) AS DOUBLE PRECISION) AS bookings_per_listing FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_4.bookings) AS bookings - , MAX(subq_9.listings) AS listings + MAX(subq_13.bookings) AS bookings + , MAX(subq_18.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.bookings + subq_12.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_2.bookings) AS bookings + SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_1.bookings + subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 - ) subq_4 + , 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_9 + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.listings + subq_17.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_7.listings) AS listings + SUM(subq_16.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_6.listings + subq_15.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.created_at__day - , subq_5.created_at__week - , subq_5.created_at__month - , subq_5.created_at__quarter - , subq_5.created_at__year - , subq_5.created_at__extract_year - , subq_5.created_at__extract_quarter - , subq_5.created_at__extract_month - , subq_5.created_at__extract_day - , subq_5.created_at__extract_dow - , subq_5.created_at__extract_doy - , subq_5.listing__ds__day - , subq_5.listing__ds__week - , subq_5.listing__ds__month - , subq_5.listing__ds__quarter - , subq_5.listing__ds__year - , subq_5.listing__ds__extract_year - , subq_5.listing__ds__extract_quarter - , subq_5.listing__ds__extract_month - , subq_5.listing__ds__extract_day - , subq_5.listing__ds__extract_dow - , subq_5.listing__ds__extract_doy - , subq_5.listing__created_at__day - , subq_5.listing__created_at__week - , subq_5.listing__created_at__month - , subq_5.listing__created_at__quarter - , subq_5.listing__created_at__year - , subq_5.listing__created_at__extract_year - , subq_5.listing__created_at__extract_quarter - , subq_5.listing__created_at__extract_month - , subq_5.listing__created_at__extract_day - , subq_5.listing__created_at__extract_dow - , subq_5.listing__created_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.user - , subq_5.listing__user - , subq_5.country_latest - , subq_5.is_lux_latest - , subq_5.capacity_latest - , subq_5.listing__country_latest - , subq_5.listing__is_lux_latest - , subq_5.listing__capacity_latest - , subq_5.listings - , subq_5.largest_listing - , subq_5.smallest_listing + 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.created_at__day + , subq_14.created_at__week + , subq_14.created_at__month + , subq_14.created_at__quarter + , subq_14.created_at__year + , subq_14.created_at__extract_year + , subq_14.created_at__extract_quarter + , subq_14.created_at__extract_month + , subq_14.created_at__extract_day + , subq_14.created_at__extract_dow + , subq_14.created_at__extract_doy + , subq_14.listing__ds__day + , subq_14.listing__ds__week + , subq_14.listing__ds__month + , subq_14.listing__ds__quarter + , subq_14.listing__ds__year + , subq_14.listing__ds__extract_year + , subq_14.listing__ds__extract_quarter + , subq_14.listing__ds__extract_month + , subq_14.listing__ds__extract_day + , subq_14.listing__ds__extract_dow + , subq_14.listing__ds__extract_doy + , subq_14.listing__created_at__day + , subq_14.listing__created_at__week + , subq_14.listing__created_at__month + , subq_14.listing__created_at__quarter + , subq_14.listing__created_at__year + , subq_14.listing__created_at__extract_year + , subq_14.listing__created_at__extract_quarter + , subq_14.listing__created_at__extract_month + , subq_14.listing__created_at__extract_day + , subq_14.listing__created_at__extract_dow + , subq_14.listing__created_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.user + , subq_14.listing__user + , subq_14.country_latest + , subq_14.is_lux_latest + , subq_14.capacity_latest + , subq_14.listing__country_latest + , subq_14.listing__is_lux_latest + , subq_14.listing__capacity_latest + , subq_14.listings + , subq_14.largest_listing + , subq_14.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_5 - ) subq_6 - ) subq_7 - ) subq_8 - ) subq_9 -) subq_10 + , 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_14 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index 201c81c126..a2c5f08fc7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_15.bookings) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_20.listings), 0) AS DOUBLE PRECISION) AS bookings_per_listing + CAST(MAX(subq_24.bookings) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_29.listings), 0) AS DOUBLE PRECISION) AS bookings_per_listing FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -10,8 +10,8 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_24 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -20,5 +20,5 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_20 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_29 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_categorical__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_categorical__plan0.sql index f5a38c336c..c8c44e9886 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_categorical__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_categorical__plan0.sql @@ -10,62 +10,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 GROUP BY subq_0.listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_categorical__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_categorical__plan0_optimized.sql index c1da0c0382..a8d1afa6a8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_categorical__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_categorical__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 GROUP BY country ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time__plan0.sql index 3bce77fb28..0675d4b77f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY subq_0.booking__paid_at__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time__plan0_optimized.sql index 280b915894..e6a861c58f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__day',] SELECT DATE_TRUNC('day', paid_at) AS booking__paid_at__day - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', paid_at) ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time_quarter__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time_quarter__plan0.sql index 53624696bc..1f038042ce 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time_quarter__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time_quarter__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY subq_0.booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time_quarter__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time_quarter__plan0_optimized.sql index f6d583edbe..5ff0fa4feb 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time_quarter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_min_max_only_time_quarter__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__quarter',] SELECT DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('quarter', paid_at) ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql index 25db7e1f1e..6c08f405fc 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__user__home_state_latest - , subq_10.bookings + subq_23.metric_time__day + , subq_23.listing__user__home_state_latest + , subq_23.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest - , SUM(subq_9.bookings) AS bookings + subq_22.metric_time__day + , subq_22.listing__user__home_state_latest + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__home_state_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__user__home_state_latest - , subq_8.bookings + subq_21.metric_time__day + , subq_21.listing__user__home_state_latest + , subq_21.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.window_start__day AS listing__window_start__day - , subq_7.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_7.user__home_state_latest AS listing__user__home_state_latest - , subq_2.bookings AS bookings + subq_15.metric_time__day AS metric_time__day + , subq_20.window_start__day AS listing__window_start__day + , subq_20.window_end__day AS listing__window_end__day + , subq_15.listing AS listing + , subq_20.user__home_state_latest AS listing__user__home_state_latest + , subq_15.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_14.metric_time__day + , subq_14.listing + , subq_14.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.user + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.booking__user + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.bookers + , subq_13.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,142 +211,142 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_13 + ) subq_14 + ) subq_15 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_6.window_start__day - , subq_6.window_end__day - , subq_6.listing - , subq_6.user__home_state_latest + subq_19.window_start__day + , subq_19.window_end__day + , subq_19.listing + , subq_19.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_3.window_start__day AS window_start__day - , subq_3.window_start__week AS window_start__week - , subq_3.window_start__month AS window_start__month - , subq_3.window_start__quarter AS window_start__quarter - , subq_3.window_start__year AS window_start__year - , subq_3.window_start__extract_year AS window_start__extract_year - , subq_3.window_start__extract_quarter AS window_start__extract_quarter - , subq_3.window_start__extract_month AS window_start__extract_month - , subq_3.window_start__extract_day AS window_start__extract_day - , subq_3.window_start__extract_dow AS window_start__extract_dow - , subq_3.window_start__extract_doy AS window_start__extract_doy - , subq_3.window_end__day AS window_end__day - , subq_3.window_end__week AS window_end__week - , subq_3.window_end__month AS window_end__month - , subq_3.window_end__quarter AS window_end__quarter - , subq_3.window_end__year AS window_end__year - , subq_3.window_end__extract_year AS window_end__extract_year - , subq_3.window_end__extract_quarter AS window_end__extract_quarter - , subq_3.window_end__extract_month AS window_end__extract_month - , subq_3.window_end__extract_day AS window_end__extract_day - , subq_3.window_end__extract_dow AS window_end__extract_dow - , subq_3.window_end__extract_doy AS window_end__extract_doy - , subq_3.listing__window_start__day AS listing__window_start__day - , subq_3.listing__window_start__week AS listing__window_start__week - , subq_3.listing__window_start__month AS listing__window_start__month - , subq_3.listing__window_start__quarter AS listing__window_start__quarter - , subq_3.listing__window_start__year AS listing__window_start__year - , subq_3.listing__window_start__extract_year AS listing__window_start__extract_year - , subq_3.listing__window_start__extract_quarter AS listing__window_start__extract_quarter - , subq_3.listing__window_start__extract_month AS listing__window_start__extract_month - , subq_3.listing__window_start__extract_day AS listing__window_start__extract_day - , subq_3.listing__window_start__extract_dow AS listing__window_start__extract_dow - , subq_3.listing__window_start__extract_doy AS listing__window_start__extract_doy - , subq_3.listing__window_end__day AS listing__window_end__day - , subq_3.listing__window_end__week AS listing__window_end__week - , subq_3.listing__window_end__month AS listing__window_end__month - , subq_3.listing__window_end__quarter AS listing__window_end__quarter - , subq_3.listing__window_end__year AS listing__window_end__year - , subq_3.listing__window_end__extract_year AS listing__window_end__extract_year - , subq_3.listing__window_end__extract_quarter AS listing__window_end__extract_quarter - , subq_3.listing__window_end__extract_month AS listing__window_end__extract_month - , subq_3.listing__window_end__extract_day AS listing__window_end__extract_day - , subq_3.listing__window_end__extract_dow AS listing__window_end__extract_dow - , subq_3.listing__window_end__extract_doy AS listing__window_end__extract_doy - , subq_5.ds__day AS user__ds__day - , subq_5.ds__week AS user__ds__week - , subq_5.ds__month AS user__ds__month - , subq_5.ds__quarter AS user__ds__quarter - , subq_5.ds__year AS user__ds__year - , subq_5.ds__extract_year AS user__ds__extract_year - , subq_5.ds__extract_quarter AS user__ds__extract_quarter - , subq_5.ds__extract_month AS user__ds__extract_month - , subq_5.ds__extract_day AS user__ds__extract_day - , subq_5.ds__extract_dow AS user__ds__extract_dow - , subq_5.ds__extract_doy AS user__ds__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country AS country - , subq_3.is_lux AS is_lux - , subq_3.capacity AS capacity - , subq_3.listing__country AS listing__country - , subq_3.listing__is_lux AS listing__is_lux - , subq_3.listing__capacity AS listing__capacity - , subq_5.home_state_latest AS user__home_state_latest + subq_16.window_start__day AS window_start__day + , subq_16.window_start__week AS window_start__week + , subq_16.window_start__month AS window_start__month + , subq_16.window_start__quarter AS window_start__quarter + , subq_16.window_start__year AS window_start__year + , subq_16.window_start__extract_year AS window_start__extract_year + , subq_16.window_start__extract_quarter AS window_start__extract_quarter + , subq_16.window_start__extract_month AS window_start__extract_month + , subq_16.window_start__extract_day AS window_start__extract_day + , subq_16.window_start__extract_dow AS window_start__extract_dow + , subq_16.window_start__extract_doy AS window_start__extract_doy + , subq_16.window_end__day AS window_end__day + , subq_16.window_end__week AS window_end__week + , subq_16.window_end__month AS window_end__month + , subq_16.window_end__quarter AS window_end__quarter + , subq_16.window_end__year AS window_end__year + , subq_16.window_end__extract_year AS window_end__extract_year + , subq_16.window_end__extract_quarter AS window_end__extract_quarter + , subq_16.window_end__extract_month AS window_end__extract_month + , subq_16.window_end__extract_day AS window_end__extract_day + , subq_16.window_end__extract_dow AS window_end__extract_dow + , subq_16.window_end__extract_doy AS window_end__extract_doy + , subq_16.listing__window_start__day AS listing__window_start__day + , subq_16.listing__window_start__week AS listing__window_start__week + , subq_16.listing__window_start__month AS listing__window_start__month + , subq_16.listing__window_start__quarter AS listing__window_start__quarter + , subq_16.listing__window_start__year AS listing__window_start__year + , subq_16.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_16.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_16.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_16.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_16.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_16.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_16.listing__window_end__day AS listing__window_end__day + , subq_16.listing__window_end__week AS listing__window_end__week + , subq_16.listing__window_end__month AS listing__window_end__month + , subq_16.listing__window_end__quarter AS listing__window_end__quarter + , subq_16.listing__window_end__year AS listing__window_end__year + , subq_16.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_16.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_16.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_16.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_16.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_16.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_18.ds__day AS user__ds__day + , subq_18.ds__week AS user__ds__week + , subq_18.ds__month AS user__ds__month + , subq_18.ds__quarter AS user__ds__quarter + , subq_18.ds__year AS user__ds__year + , subq_18.ds__extract_year AS user__ds__extract_year + , subq_18.ds__extract_quarter AS user__ds__extract_quarter + , subq_18.ds__extract_month AS user__ds__extract_month + , subq_18.ds__extract_day AS user__ds__extract_day + , subq_18.ds__extract_dow AS user__ds__extract_dow + , subq_18.ds__extract_doy AS user__ds__extract_doy + , subq_16.listing AS listing + , subq_16.user AS user + , subq_16.listing__user AS listing__user + , subq_16.country AS country + , subq_16.is_lux AS is_lux + , subq_16.capacity AS capacity + , subq_16.listing__country AS listing__country + , subq_16.listing__is_lux AS listing__is_lux + , subq_16.listing__capacity AS listing__capacity + , subq_18.home_state_latest AS user__home_state_latest FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , EXTRACT(isodow FROM listings_src_26002.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , EXTRACT(isodow FROM listings_src_26000.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_16 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,83 +376,83 @@ FROM ( -- 'user', -- ] SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.user__ds__day - , subq_4.user__ds__week - , subq_4.user__ds__month - , subq_4.user__ds__quarter - , subq_4.user__ds__year - , subq_4.user__ds__extract_year - , subq_4.user__ds__extract_quarter - , subq_4.user__ds__extract_month - , subq_4.user__ds__extract_day - , subq_4.user__ds__extract_dow - , subq_4.user__ds__extract_doy - , subq_4.user - , subq_4.home_state_latest - , subq_4.user__home_state_latest + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.user__ds__day + , subq_17.user__ds__week + , subq_17.user__ds__month + , subq_17.user__ds__quarter + , subq_17.user__ds__year + , subq_17.user__ds__extract_year + , subq_17.user__ds__extract_quarter + , subq_17.user__ds__extract_month + , subq_17.user__ds__extract_day + , subq_17.user__ds__extract_dow + , subq_17.user__ds__extract_doy + , subq_17.user + , subq_17.home_state_latest + , subq_17.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_26006.ds) AS ds__day - , DATE_TRUNC('week', users_latest_src_26006.ds) AS ds__week - , DATE_TRUNC('month', users_latest_src_26006.ds) AS ds__month - , DATE_TRUNC('quarter', users_latest_src_26006.ds) AS ds__quarter - , DATE_TRUNC('year', users_latest_src_26006.ds) AS ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS ds__extract_day - , EXTRACT(isodow FROM users_latest_src_26006.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_latest_src_26006.ds) AS ds__extract_doy - , users_latest_src_26006.home_state_latest - , DATE_TRUNC('day', users_latest_src_26006.ds) AS user__ds__day - , DATE_TRUNC('week', users_latest_src_26006.ds) AS user__ds__week - , DATE_TRUNC('month', users_latest_src_26006.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_latest_src_26006.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_latest_src_26006.ds) AS user__ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS user__ds__extract_day - , EXTRACT(isodow FROM users_latest_src_26006.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_latest_src_26006.ds) AS user__ds__extract_doy - , users_latest_src_26006.home_state_latest AS user__home_state_latest - , users_latest_src_26006.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_26006 - ) subq_4 - ) subq_5 + DATE_TRUNC('day', users_latest_src_26000.ds) AS ds__day + , DATE_TRUNC('week', users_latest_src_26000.ds) AS ds__week + , DATE_TRUNC('month', users_latest_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', users_latest_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', users_latest_src_26000.ds) AS ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_latest_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_latest_src_26000.ds) AS ds__extract_doy + , users_latest_src_26000.home_state_latest + , DATE_TRUNC('day', users_latest_src_26000.ds) AS user__ds__day + , DATE_TRUNC('week', users_latest_src_26000.ds) AS user__ds__week + , DATE_TRUNC('month', users_latest_src_26000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_latest_src_26000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_latest_src_26000.ds) AS user__ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_latest_src_26000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_latest_src_26000.ds) AS user__ds__extract_doy + , users_latest_src_26000.home_state_latest AS user__home_state_latest + , users_latest_src_26000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_26000 + ) subq_17 + ) subq_18 ON - subq_3.user = subq_5.user - ) subq_6 - ) subq_7 + subq_16.user = subq_18.user + ) subq_19 + ) subq_20 ON ( - subq_2.listing = subq_7.listing + subq_15.listing = subq_20.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.window_start__day + subq_15.metric_time__day >= subq_20.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.window_end__day + subq_15.metric_time__day < subq_20.window_end__day ) OR ( - subq_7.window_end__day IS NULL + subq_20.window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_21 + ) subq_22 GROUP BY - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest -) subq_10 + subq_22.metric_time__day + , subq_22.listing__user__home_state_latest +) subq_23 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 1d7e6c24a7..f38afda4f7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.user__home_state_latest AS listing__user__home_state_latest - , SUM(subq_13.bookings) AS bookings + subq_26.metric_time__day AS metric_time__day + , subq_31.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_26.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,35 +15,35 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_26 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - listings_src_26002.active_from AS window_start__day - , listings_src_26002.active_to AS window_end__day - , listings_src_26002.listing_id AS listing - , users_latest_src_26006.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings listings_src_26002 + listings_src_26000.active_from AS window_start__day + , listings_src_26000.active_to AS window_end__day + , listings_src_26000.listing_id AS listing + , users_latest_src_26000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings listings_src_26000 LEFT OUTER JOIN - ***************************.dim_users_latest users_latest_src_26006 + ***************************.dim_users_latest users_latest_src_26000 ON - listings_src_26002.user_id = users_latest_src_26006.user_id -) subq_18 + listings_src_26000.user_id = users_latest_src_26000.user_id +) subq_31 ON ( - subq_13.listing = subq_18.listing + subq_26.listing = subq_31.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_26.metric_time__day >= subq_31.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_26.metric_time__day < subq_31.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_31.window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.user__home_state_latest + subq_26.metric_time__day + , subq_31.user__home_state_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql index 98c67a81c2..b44d8b709b 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__lux_listing__is_confirmed_lux - , subq_10.bookings + subq_15.metric_time__day + , subq_15.listing__lux_listing__is_confirmed_lux + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux - , SUM(subq_9.bookings) AS bookings + subq_14.metric_time__day + , subq_14.listing__lux_listing__is_confirmed_lux + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__lux_listing__is_confirmed_lux', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__lux_listing__is_confirmed_lux - , subq_8.bookings + subq_13.metric_time__day + , subq_13.listing__lux_listing__is_confirmed_lux + , subq_13.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.lux_listing__window_start__day AS listing__lux_listing__window_start__day - , subq_7.lux_listing__window_end__day AS listing__lux_listing__window_end__day - , subq_2.listing AS listing - , subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , subq_2.bookings AS bookings + subq_7.metric_time__day AS metric_time__day + , subq_12.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_12.lux_listing__window_end__day AS listing__lux_listing__window_end__day + , subq_7.listing AS listing + , subq_12.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_7.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_6.metric_time__day + , subq_6.listing + , subq_6.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.ds__day AS metric_time__day + , subq_5.ds__week AS metric_time__week + , subq_5.ds__month AS metric_time__month + , subq_5.ds__quarter AS metric_time__quarter + , subq_5.ds__year AS metric_time__year + , subq_5.ds__extract_year AS metric_time__extract_year + , subq_5.ds__extract_quarter AS metric_time__extract_quarter + , subq_5.ds__extract_month AS metric_time__extract_month + , subq_5.ds__extract_day AS metric_time__extract_day + , subq_5.ds__extract_dow AS metric_time__extract_dow + , subq_5.ds__extract_doy AS metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.user + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.booking__user + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.bookings + , subq_5.instant_bookings + , subq_5.booking_value + , subq_5.bookers + , subq_5.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,53 +211,53 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_5 + ) subq_6 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - subq_6.lux_listing__window_start__day - , subq_6.lux_listing__window_end__day - , subq_6.listing - , subq_6.lux_listing__is_confirmed_lux + subq_11.lux_listing__window_start__day + , subq_11.lux_listing__window_end__day + , subq_11.listing + , subq_11.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_5.window_start__day AS lux_listing__window_start__day - , subq_5.window_start__week AS lux_listing__window_start__week - , subq_5.window_start__month AS lux_listing__window_start__month - , subq_5.window_start__quarter AS lux_listing__window_start__quarter - , subq_5.window_start__year AS lux_listing__window_start__year - , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_5.window_end__day AS lux_listing__window_end__day - , subq_5.window_end__week AS lux_listing__window_end__week - , subq_5.window_end__month AS lux_listing__window_end__month - , subq_5.window_end__quarter AS lux_listing__window_end__quarter - , subq_5.window_end__year AS lux_listing__window_end__year - , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_3.listing AS listing - , subq_3.lux_listing AS lux_listing - , subq_3.listing__lux_listing AS listing__lux_listing - , subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux + subq_10.window_start__day AS lux_listing__window_start__day + , subq_10.window_start__week AS lux_listing__window_start__week + , subq_10.window_start__month AS lux_listing__window_start__month + , subq_10.window_start__quarter AS lux_listing__window_start__quarter + , subq_10.window_start__year AS lux_listing__window_start__year + , subq_10.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_10.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_10.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_10.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_10.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_10.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_10.window_end__day AS lux_listing__window_end__day + , subq_10.window_end__week AS lux_listing__window_end__week + , subq_10.window_end__month AS lux_listing__window_end__month + , subq_10.window_end__quarter AS lux_listing__window_end__quarter + , subq_10.window_end__year AS lux_listing__window_end__year + , subq_10.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_10.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_10.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_10.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_10.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_10.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_8.listing AS listing + , subq_8.lux_listing AS lux_listing + , subq_8.listing__lux_listing AS listing__lux_listing + , subq_10.is_confirmed_lux AS lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT - lux_listing_mapping_src_26003.listing_id AS listing - , lux_listing_mapping_src_26003.lux_listing_id AS lux_listing - , lux_listing_mapping_src_26003.lux_listing_id AS listing__lux_listing - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 - ) subq_3 + lux_listing_mapping_src_26000.listing_id AS listing + , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing + , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 + ) subq_8 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,127 +309,127 @@ FROM ( -- 'lux_listing', -- ] SELECT - subq_4.window_start__day - , subq_4.window_start__week - , subq_4.window_start__month - , subq_4.window_start__quarter - , subq_4.window_start__year - , subq_4.window_start__extract_year - , subq_4.window_start__extract_quarter - , subq_4.window_start__extract_month - , subq_4.window_start__extract_day - , subq_4.window_start__extract_dow - , subq_4.window_start__extract_doy - , subq_4.window_end__day - , subq_4.window_end__week - , subq_4.window_end__month - , subq_4.window_end__quarter - , subq_4.window_end__year - , subq_4.window_end__extract_year - , subq_4.window_end__extract_quarter - , subq_4.window_end__extract_month - , subq_4.window_end__extract_day - , subq_4.window_end__extract_dow - , subq_4.window_end__extract_doy - , subq_4.lux_listing__window_start__day - , subq_4.lux_listing__window_start__week - , subq_4.lux_listing__window_start__month - , subq_4.lux_listing__window_start__quarter - , subq_4.lux_listing__window_start__year - , subq_4.lux_listing__window_start__extract_year - , subq_4.lux_listing__window_start__extract_quarter - , subq_4.lux_listing__window_start__extract_month - , subq_4.lux_listing__window_start__extract_day - , subq_4.lux_listing__window_start__extract_dow - , subq_4.lux_listing__window_start__extract_doy - , subq_4.lux_listing__window_end__day - , subq_4.lux_listing__window_end__week - , subq_4.lux_listing__window_end__month - , subq_4.lux_listing__window_end__quarter - , subq_4.lux_listing__window_end__year - , subq_4.lux_listing__window_end__extract_year - , subq_4.lux_listing__window_end__extract_quarter - , subq_4.lux_listing__window_end__extract_month - , subq_4.lux_listing__window_end__extract_day - , subq_4.lux_listing__window_end__extract_dow - , subq_4.lux_listing__window_end__extract_doy - , subq_4.lux_listing - , subq_4.is_confirmed_lux - , subq_4.lux_listing__is_confirmed_lux + subq_9.window_start__day + , subq_9.window_start__week + , subq_9.window_start__month + , subq_9.window_start__quarter + , subq_9.window_start__year + , subq_9.window_start__extract_year + , subq_9.window_start__extract_quarter + , subq_9.window_start__extract_month + , subq_9.window_start__extract_day + , subq_9.window_start__extract_dow + , subq_9.window_start__extract_doy + , subq_9.window_end__day + , subq_9.window_end__week + , subq_9.window_end__month + , subq_9.window_end__quarter + , subq_9.window_end__year + , subq_9.window_end__extract_year + , subq_9.window_end__extract_quarter + , subq_9.window_end__extract_month + , subq_9.window_end__extract_day + , subq_9.window_end__extract_dow + , subq_9.window_end__extract_doy + , subq_9.lux_listing__window_start__day + , subq_9.lux_listing__window_start__week + , subq_9.lux_listing__window_start__month + , subq_9.lux_listing__window_start__quarter + , subq_9.lux_listing__window_start__year + , subq_9.lux_listing__window_start__extract_year + , subq_9.lux_listing__window_start__extract_quarter + , subq_9.lux_listing__window_start__extract_month + , subq_9.lux_listing__window_start__extract_day + , subq_9.lux_listing__window_start__extract_dow + , subq_9.lux_listing__window_start__extract_doy + , subq_9.lux_listing__window_end__day + , subq_9.lux_listing__window_end__week + , subq_9.lux_listing__window_end__month + , subq_9.lux_listing__window_end__quarter + , subq_9.lux_listing__window_end__year + , subq_9.lux_listing__window_end__extract_year + , subq_9.lux_listing__window_end__extract_quarter + , subq_9.lux_listing__window_end__extract_month + , subq_9.lux_listing__window_end__extract_day + , subq_9.lux_listing__window_end__extract_dow + , subq_9.lux_listing__window_end__extract_doy + , subq_9.lux_listing + , subq_9.is_confirmed_lux + , subq_9.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT - lux_listings_src_26004.valid_from AS window_start__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_from) AS window_start__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_from) AS window_start__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_from) AS window_start__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_from) AS window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS window_start__extract_day - , EXTRACT(isodow FROM lux_listings_src_26004.valid_from) AS window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_from) AS window_start__extract_doy - , lux_listings_src_26004.valid_to AS window_end__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_to) AS window_end__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_to) AS window_end__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_to) AS window_end__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_to) AS window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS window_end__extract_day - , EXTRACT(isodow FROM lux_listings_src_26004.valid_to) AS window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_to) AS window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux - , lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_from) AS lux_listing__window_start__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_from) AS lux_listing__window_start__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_from) AS lux_listing__window_start__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_from) AS lux_listing__window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_day - , EXTRACT(isodow FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_doy - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_to) AS lux_listing__window_end__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_to) AS lux_listing__window_end__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_to) AS lux_listing__window_end__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_to) AS lux_listing__window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_day - , EXTRACT(isodow FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - , lux_listings_src_26004.lux_listing_id AS lux_listing - FROM ***************************.dim_lux_listings lux_listings_src_26004 - ) subq_4 - ) subq_5 + lux_listings_src_26000.valid_from AS window_start__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_from) AS window_start__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_from) AS window_start__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_from) AS window_start__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_from) AS window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS window_start__extract_day + , EXTRACT(isodow FROM lux_listings_src_26000.valid_from) AS window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_from) AS window_start__extract_doy + , lux_listings_src_26000.valid_to AS window_end__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_to) AS window_end__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_to) AS window_end__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_to) AS window_end__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_to) AS window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS window_end__extract_day + , EXTRACT(isodow FROM lux_listings_src_26000.valid_to) AS window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_to) AS window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux + , lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_from) AS lux_listing__window_start__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_from) AS lux_listing__window_start__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_from) AS lux_listing__window_start__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_from) AS lux_listing__window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_day + , EXTRACT(isodow FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_doy + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_to) AS lux_listing__window_end__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_to) AS lux_listing__window_end__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_to) AS lux_listing__window_end__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_to) AS lux_listing__window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_day + , EXTRACT(isodow FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + , lux_listings_src_26000.lux_listing_id AS lux_listing + FROM ***************************.dim_lux_listings lux_listings_src_26000 + ) subq_9 + ) subq_10 ON - subq_3.lux_listing = subq_5.lux_listing - ) subq_6 - ) subq_7 + subq_8.lux_listing = subq_10.lux_listing + ) subq_11 + ) subq_12 ON ( - subq_2.listing = subq_7.listing + subq_7.listing = subq_12.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.lux_listing__window_start__day + subq_7.metric_time__day >= subq_12.lux_listing__window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.lux_listing__window_end__day + subq_7.metric_time__day < subq_12.lux_listing__window_end__day ) OR ( - subq_7.lux_listing__window_end__day IS NULL + subq_12.lux_listing__window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_13 + ) subq_14 GROUP BY - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux -) subq_10 + subq_14.metric_time__day + , subq_14.listing__lux_listing__is_confirmed_lux +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql index 0ef5f08ffa..eb9b15d13c 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , SUM(subq_13.bookings) AS bookings + subq_18.metric_time__day AS metric_time__day + , subq_23.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_18.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,35 +15,35 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_18 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , lux_listing_mapping_src_26003.listing_id AS listing - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 + lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , lux_listing_mapping_src_26000.listing_id AS listing + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 LEFT OUTER JOIN - ***************************.dim_lux_listings lux_listings_src_26004 + ***************************.dim_lux_listings lux_listings_src_26000 ON - lux_listing_mapping_src_26003.lux_listing_id = lux_listings_src_26004.lux_listing_id -) subq_18 + lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id +) subq_23 ON ( - subq_13.listing = subq_18.listing + subq_18.listing = subq_23.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.lux_listing__window_start__day + subq_18.metric_time__day >= subq_23.lux_listing__window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.lux_listing__window_end__day + subq_18.metric_time__day < subq_23.lux_listing__window_end__day ) OR ( - subq_18.lux_listing__window_end__day IS NULL + subq_23.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.lux_listing__is_confirmed_lux + subq_18.metric_time__day + , subq_23.lux_listing__is_confirmed_lux diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql index ebedc871a4..434656619b 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql @@ -1,93 +1,93 @@ -- Compute Metrics via Expressions SELECT - subq_10.account_id__customer_id__customer_name - , subq_10.txn_count + subq_14.account_id__customer_id__customer_name + , subq_14.txn_count FROM ( -- Aggregate Measures SELECT - subq_9.account_id__customer_id__customer_name - , SUM(subq_9.txn_count) AS txn_count + subq_13.account_id__customer_id__customer_name + , SUM(subq_13.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_8.account_id__customer_id__customer_name - , subq_8.txn_count + subq_12.account_id__customer_id__customer_name + , subq_12.txn_count FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_2.account_id AS account_id - , subq_7.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_2.txn_count AS txn_count + subq_6.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_6.account_id AS account_id + , subq_11.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_6.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_1.ds_partitioned__day - , subq_1.account_id - , subq_1.txn_count + subq_5.ds_partitioned__day + , subq_5.account_id + , subq_5.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.account_id__ds_partitioned__day - , subq_0.account_id__ds_partitioned__week - , subq_0.account_id__ds_partitioned__month - , subq_0.account_id__ds_partitioned__quarter - , subq_0.account_id__ds_partitioned__year - , subq_0.account_id__ds_partitioned__extract_year - , subq_0.account_id__ds_partitioned__extract_quarter - , subq_0.account_id__ds_partitioned__extract_month - , subq_0.account_id__ds_partitioned__extract_day - , subq_0.account_id__ds_partitioned__extract_dow - , subq_0.account_id__ds_partitioned__extract_doy - , subq_0.account_id__ds__day - , subq_0.account_id__ds__week - , subq_0.account_id__ds__month - , subq_0.account_id__ds__quarter - , subq_0.account_id__ds__year - , subq_0.account_id__ds__extract_year - , subq_0.account_id__ds__extract_quarter - , subq_0.account_id__ds__extract_month - , subq_0.account_id__ds__extract_day - , subq_0.account_id__ds__extract_dow - , subq_0.account_id__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.account_id - , subq_0.account_month - , subq_0.account_id__account_month - , subq_0.txn_count + subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.account_id__ds_partitioned__day + , subq_4.account_id__ds_partitioned__week + , subq_4.account_id__ds_partitioned__month + , subq_4.account_id__ds_partitioned__quarter + , subq_4.account_id__ds_partitioned__year + , subq_4.account_id__ds_partitioned__extract_year + , subq_4.account_id__ds_partitioned__extract_quarter + , subq_4.account_id__ds_partitioned__extract_month + , subq_4.account_id__ds_partitioned__extract_day + , subq_4.account_id__ds_partitioned__extract_dow + , subq_4.account_id__ds_partitioned__extract_doy + , subq_4.account_id__ds__day + , subq_4.account_id__ds__week + , subq_4.account_id__ds__month + , subq_4.account_id__ds__quarter + , subq_4.account_id__ds__year + , subq_4.account_id__ds__extract_year + , subq_4.account_id__ds__extract_quarter + , subq_4.account_id__ds__extract_month + , subq_4.account_id__ds__extract_day + , subq_4.account_id__ds__extract_dow + , subq_4.account_id__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.account_id + , subq_4.account_month + , subq_4.account_id__account_month + , subq_4.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -140,118 +140,118 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_4 + ) subq_5 + ) subq_6 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_6.ds_partitioned__day - , subq_6.account_id - , subq_6.customer_id__customer_name + subq_10.ds_partitioned__day + , subq_10.account_id + , subq_10.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_3.ds_partitioned__day AS ds_partitioned__day - , subq_3.ds_partitioned__week AS ds_partitioned__week - , subq_3.ds_partitioned__month AS ds_partitioned__month - , subq_3.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_3.ds_partitioned__year AS ds_partitioned__year - , subq_3.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_3.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_3.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_3.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_3.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_3.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_3.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_3.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_3.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_3.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_3.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_3.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_3.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_5.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_5.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_5.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_5.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_5.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_5.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_3.account_id AS account_id - , subq_3.customer_id AS customer_id - , subq_3.account_id__customer_id AS account_id__customer_id - , subq_3.bridge_account__account_id AS bridge_account__account_id - , subq_3.bridge_account__customer_id AS bridge_account__customer_id - , subq_3.extra_dim AS extra_dim - , subq_3.account_id__extra_dim AS account_id__extra_dim - , subq_3.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_5.customer_name AS customer_id__customer_name - , subq_5.customer_atomic_weight AS customer_id__customer_atomic_weight + subq_7.ds_partitioned__day AS ds_partitioned__day + , subq_7.ds_partitioned__week AS ds_partitioned__week + , subq_7.ds_partitioned__month AS ds_partitioned__month + , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_7.ds_partitioned__year AS ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_9.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_9.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_9.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_9.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_9.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_9.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_7.account_id AS account_id + , subq_7.customer_id AS customer_id + , subq_7.account_id__customer_id AS account_id__customer_id + , subq_7.bridge_account__account_id AS bridge_account__account_id + , subq_7.bridge_account__customer_id AS bridge_account__customer_id + , subq_7.extra_dim AS extra_dim + , subq_7.account_id__extra_dim AS account_id__extra_dim + , subq_7.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_9.customer_name AS customer_id__customer_name + , subq_9.customer_atomic_weight AS customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT - bridge_table_src_22001.extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS account_id__extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(isodow FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS bridge_account__extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_day - , EXTRACT(isodow FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy - , bridge_table_src_22001.account_id - , bridge_table_src_22001.customer_id - , bridge_table_src_22001.customer_id AS account_id__customer_id - , bridge_table_src_22001.account_id AS bridge_account__account_id - , bridge_table_src_22001.customer_id AS bridge_account__customer_id - FROM ***************************.bridge_table bridge_table_src_22001 - ) subq_3 + bridge_table_src_22000.extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS account_id__extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(isodow FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS bridge_account__extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_day + , EXTRACT(isodow FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy + , bridge_table_src_22000.account_id + , bridge_table_src_22000.customer_id + , bridge_table_src_22000.customer_id AS account_id__customer_id + , bridge_table_src_22000.account_id AS bridge_account__account_id + , bridge_table_src_22000.customer_id AS bridge_account__customer_id + FROM ***************************.bridge_table bridge_table_src_22000 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -283,82 +283,82 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.customer_id__ds_partitioned__day - , subq_4.customer_id__ds_partitioned__week - , subq_4.customer_id__ds_partitioned__month - , subq_4.customer_id__ds_partitioned__quarter - , subq_4.customer_id__ds_partitioned__year - , subq_4.customer_id__ds_partitioned__extract_year - , subq_4.customer_id__ds_partitioned__extract_quarter - , subq_4.customer_id__ds_partitioned__extract_month - , subq_4.customer_id__ds_partitioned__extract_day - , subq_4.customer_id__ds_partitioned__extract_dow - , subq_4.customer_id__ds_partitioned__extract_doy - , subq_4.customer_id - , subq_4.customer_name - , subq_4.customer_atomic_weight - , subq_4.customer_id__customer_name - , subq_4.customer_id__customer_atomic_weight + subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.customer_id__ds_partitioned__day + , subq_8.customer_id__ds_partitioned__week + , subq_8.customer_id__ds_partitioned__month + , subq_8.customer_id__ds_partitioned__quarter + , subq_8.customer_id__ds_partitioned__year + , subq_8.customer_id__ds_partitioned__extract_year + , subq_8.customer_id__ds_partitioned__extract_quarter + , subq_8.customer_id__ds_partitioned__extract_month + , subq_8.customer_id__ds_partitioned__extract_day + , subq_8.customer_id__ds_partitioned__extract_dow + , subq_8.customer_id__ds_partitioned__extract_doy + , subq_8.customer_id + , subq_8.customer_name + , subq_8.customer_atomic_weight + , subq_8.customer_id__customer_name + , subq_8.customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT - customer_table_src_22003.customer_name - , customer_table_src_22003.customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_22003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_22003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_22003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_22003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_doy - , customer_table_src_22003.customer_name AS customer_id__customer_name - , customer_table_src_22003.customer_atomic_weight AS customer_id__customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_day - , EXTRACT(isodow FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_doy - , customer_table_src_22003.customer_id - FROM ***************************.customer_table customer_table_src_22003 - ) subq_4 - ) subq_5 + customer_table_src_22000.customer_name + , customer_table_src_22000.customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , customer_table_src_22000.customer_name AS customer_id__customer_name + , customer_table_src_22000.customer_atomic_weight AS customer_id__customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_day + , EXTRACT(isodow FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy + , customer_table_src_22000.customer_id + FROM ***************************.customer_table customer_table_src_22000 + ) subq_8 + ) subq_9 ON ( - subq_3.customer_id = subq_5.customer_id + subq_7.customer_id = subq_9.customer_id ) AND ( - subq_3.ds_partitioned__day = subq_5.ds_partitioned__day + subq_7.ds_partitioned__day = subq_9.ds_partitioned__day ) - ) subq_6 - ) subq_7 + ) subq_10 + ) subq_11 ON ( - subq_2.account_id = subq_7.account_id + subq_6.account_id = subq_11.account_id ) AND ( - subq_2.ds_partitioned__day = subq_7.ds_partitioned__day + subq_6.ds_partitioned__day = subq_11.ds_partitioned__day ) - ) subq_8 - ) subq_9 + ) subq_12 + ) subq_13 GROUP BY - subq_9.account_id__customer_id__customer_name -) subq_10 + subq_13.account_id__customer_id__customer_name +) subq_14 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql index 7802d2f867..13473156ca 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql @@ -3,31 +3,31 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_18.customer_id__customer_name AS account_id__customer_id__customer_name + subq_22.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__day - , bridge_table_src_22001.account_id AS account_id - , customer_table_src_22003.customer_name AS customer_id__customer_name - FROM ***************************.bridge_table bridge_table_src_22001 + DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__day + , bridge_table_src_22000.account_id AS account_id + , customer_table_src_22000.customer_name AS customer_id__customer_name + FROM ***************************.bridge_table bridge_table_src_22000 LEFT OUTER JOIN - ***************************.customer_table customer_table_src_22003 + ***************************.customer_table customer_table_src_22000 ON ( - bridge_table_src_22001.customer_id = customer_table_src_22003.customer_id + bridge_table_src_22000.customer_id = customer_table_src_22000.customer_id ) AND ( - DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) + DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_18 +) subq_22 ON ( - account_month_txns_src_22000.account_id = subq_18.account_id + account_month_txns_src_22000.account_id = subq_22.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day ) GROUP BY - subq_18.customer_id__customer_name + subq_22.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql index 819dc05fc2..b420a6ff2b 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql @@ -1,536 +1,536 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_5.bookings) AS bookings - , MAX(subq_11.listings) AS listings + MAX(subq_18.bookings) AS bookings + , MAX(subq_24.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_4.bookings + subq_17.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_3.bookings) AS bookings + SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_2.bookings + subq_15.bookings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.ds_partitioned__day - , subq_1.ds_partitioned__week - , subq_1.ds_partitioned__month - , subq_1.ds_partitioned__quarter - , subq_1.ds_partitioned__year - , subq_1.ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy - , subq_1.paid_at__day - , subq_1.paid_at__week - , subq_1.paid_at__month - , subq_1.paid_at__quarter - , subq_1.paid_at__year - , subq_1.paid_at__extract_year - , subq_1.paid_at__extract_quarter - , subq_1.paid_at__extract_month - , subq_1.paid_at__extract_day - , subq_1.paid_at__extract_dow - , subq_1.paid_at__extract_doy - , subq_1.booking__ds__day - , subq_1.booking__ds__week - , subq_1.booking__ds__month - , subq_1.booking__ds__quarter - , subq_1.booking__ds__year - , subq_1.booking__ds__extract_year - , subq_1.booking__ds__extract_quarter - , subq_1.booking__ds__extract_month - , subq_1.booking__ds__extract_day - , subq_1.booking__ds__extract_dow - , subq_1.booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day - , subq_1.booking__paid_at__week - , subq_1.booking__paid_at__month - , subq_1.booking__paid_at__quarter - , subq_1.booking__paid_at__year - , subq_1.booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.listing - , subq_1.guest - , subq_1.host - , subq_1.booking__listing - , subq_1.booking__guest - , subq_1.booking__host - , subq_1.is_instant - , subq_1.booking__is_instant - , subq_1.bookings - , subq_1.instant_bookings - , subq_1.booking_value - , subq_1.max_booking_value - , subq_1.min_booking_value - , subq_1.bookers - , subq_1.average_booking_value - , subq_1.referred_bookings - , subq_1.median_booking_value - , subq_1.booking_value_p99 - , subq_1.discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 + subq_14.ds__day + , subq_14.ds__week + , subq_14.ds__month + , subq_14.ds__quarter + , subq_14.ds__year + , subq_14.ds__extract_year + , subq_14.ds__extract_quarter + , subq_14.ds__extract_month + , subq_14.ds__extract_day + , subq_14.ds__extract_dow + , subq_14.ds__extract_doy + , subq_14.ds_partitioned__day + , subq_14.ds_partitioned__week + , subq_14.ds_partitioned__month + , subq_14.ds_partitioned__quarter + , subq_14.ds_partitioned__year + , subq_14.ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy + , subq_14.paid_at__day + , subq_14.paid_at__week + , subq_14.paid_at__month + , subq_14.paid_at__quarter + , subq_14.paid_at__year + , subq_14.paid_at__extract_year + , subq_14.paid_at__extract_quarter + , subq_14.paid_at__extract_month + , subq_14.paid_at__extract_day + , subq_14.paid_at__extract_dow + , subq_14.paid_at__extract_doy + , subq_14.booking__ds__day + , subq_14.booking__ds__week + , subq_14.booking__ds__month + , subq_14.booking__ds__quarter + , subq_14.booking__ds__year + , subq_14.booking__ds__extract_year + , subq_14.booking__ds__extract_quarter + , subq_14.booking__ds__extract_month + , subq_14.booking__ds__extract_day + , subq_14.booking__ds__extract_dow + , subq_14.booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day + , subq_14.booking__paid_at__week + , subq_14.booking__paid_at__month + , subq_14.booking__paid_at__quarter + , subq_14.booking__paid_at__year + , subq_14.booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy + , subq_14.metric_time__day + , subq_14.metric_time__week + , subq_14.metric_time__month + , subq_14.metric_time__quarter + , subq_14.metric_time__year + , subq_14.metric_time__extract_year + , subq_14.metric_time__extract_quarter + , subq_14.metric_time__extract_month + , subq_14.metric_time__extract_day + , subq_14.metric_time__extract_dow + , subq_14.metric_time__extract_doy + , subq_14.listing + , subq_14.guest + , subq_14.host + , subq_14.booking__listing + , subq_14.booking__guest + , subq_14.booking__host + , subq_14.is_instant + , subq_14.booking__is_instant + , subq_14.bookings + , subq_14.instant_bookings + , subq_14.booking_value + , subq_14.max_booking_value + , subq_14.min_booking_value + , subq_14.bookers + , subq_14.average_booking_value + , subq_14.referred_bookings + , subq_14.median_booking_value + , subq_14.booking_value_p99 + , subq_14.discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_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 + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.max_booking_value + , subq_13.min_booking_value + , subq_13.bookers + , subq_13.average_booking_value + , subq_13.referred_bookings + , subq_13.median_booking_value + , subq_13.booking_value_p99 + , subq_13.discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_2 - ) subq_3 - ) subq_4 -) subq_5 + , 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_13 + ) subq_14 + WHERE subq_14.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_15 + ) subq_16 + ) subq_17 +) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.listings + subq_23.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_9.listings) AS listings + SUM(subq_22.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_8.listings + subq_21.listings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] 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.created_at__day - , subq_7.created_at__week - , subq_7.created_at__month - , subq_7.created_at__quarter - , subq_7.created_at__year - , subq_7.created_at__extract_year - , subq_7.created_at__extract_quarter - , subq_7.created_at__extract_month - , subq_7.created_at__extract_day - , subq_7.created_at__extract_dow - , subq_7.created_at__extract_doy - , subq_7.listing__ds__day - , subq_7.listing__ds__week - , subq_7.listing__ds__month - , subq_7.listing__ds__quarter - , subq_7.listing__ds__year - , subq_7.listing__ds__extract_year - , subq_7.listing__ds__extract_quarter - , subq_7.listing__ds__extract_month - , subq_7.listing__ds__extract_day - , subq_7.listing__ds__extract_dow - , subq_7.listing__ds__extract_doy - , subq_7.listing__created_at__day - , subq_7.listing__created_at__week - , subq_7.listing__created_at__month - , subq_7.listing__created_at__quarter - , subq_7.listing__created_at__year - , subq_7.listing__created_at__extract_year - , subq_7.listing__created_at__extract_quarter - , subq_7.listing__created_at__extract_month - , subq_7.listing__created_at__extract_day - , subq_7.listing__created_at__extract_dow - , subq_7.listing__created_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.user - , subq_7.listing__user - , subq_7.country_latest - , subq_7.is_lux_latest - , subq_7.capacity_latest - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.listings - , subq_7.largest_listing - , subq_7.smallest_listing + 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.created_at__day + , subq_20.created_at__week + , subq_20.created_at__month + , subq_20.created_at__quarter + , subq_20.created_at__year + , subq_20.created_at__extract_year + , subq_20.created_at__extract_quarter + , subq_20.created_at__extract_month + , subq_20.created_at__extract_day + , subq_20.created_at__extract_dow + , subq_20.created_at__extract_doy + , subq_20.listing__ds__day + , subq_20.listing__ds__week + , subq_20.listing__ds__month + , subq_20.listing__ds__quarter + , subq_20.listing__ds__year + , subq_20.listing__ds__extract_year + , subq_20.listing__ds__extract_quarter + , subq_20.listing__ds__extract_month + , subq_20.listing__ds__extract_day + , subq_20.listing__ds__extract_dow + , subq_20.listing__ds__extract_doy + , subq_20.listing__created_at__day + , subq_20.listing__created_at__week + , subq_20.listing__created_at__month + , subq_20.listing__created_at__quarter + , subq_20.listing__created_at__year + , subq_20.listing__created_at__extract_year + , subq_20.listing__created_at__extract_quarter + , subq_20.listing__created_at__extract_month + , subq_20.listing__created_at__extract_day + , subq_20.listing__created_at__extract_dow + , subq_20.listing__created_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.user + , subq_20.listing__user + , subq_20.country_latest + , subq_20.is_lux_latest + , subq_20.capacity_latest + , subq_20.listing__country_latest + , subq_20.listing__is_lux_latest + , subq_20.listing__capacity_latest + , subq_20.listings + , subq_20.largest_listing + , subq_20.smallest_listing FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_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.created_at__day + , subq_19.created_at__week + , subq_19.created_at__month + , subq_19.created_at__quarter + , subq_19.created_at__year + , subq_19.created_at__extract_year + , subq_19.created_at__extract_quarter + , subq_19.created_at__extract_month + , subq_19.created_at__extract_day + , subq_19.created_at__extract_dow + , subq_19.created_at__extract_doy + , subq_19.listing__ds__day + , subq_19.listing__ds__week + , subq_19.listing__ds__month + , subq_19.listing__ds__quarter + , subq_19.listing__ds__year + , subq_19.listing__ds__extract_year + , subq_19.listing__ds__extract_quarter + , subq_19.listing__ds__extract_month + , subq_19.listing__ds__extract_day + , subq_19.listing__ds__extract_dow + , subq_19.listing__ds__extract_doy + , subq_19.listing__created_at__day + , subq_19.listing__created_at__week + , subq_19.listing__created_at__month + , subq_19.listing__created_at__quarter + , subq_19.listing__created_at__year + , subq_19.listing__created_at__extract_year + , subq_19.listing__created_at__extract_quarter + , subq_19.listing__created_at__extract_month + , subq_19.listing__created_at__extract_day + , subq_19.listing__created_at__extract_dow + , subq_19.listing__created_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.user + , subq_19.listing__user + , subq_19.country_latest + , subq_19.is_lux_latest + , subq_19.capacity_latest + , subq_19.listing__country_latest + , subq_19.listing__is_lux_latest + , subq_19.listing__capacity_latest + , subq_19.listings + , subq_19.largest_listing + , subq_19.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_6 - ) subq_7 - WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_8 - ) subq_9 - ) subq_10 -) subq_11 + , 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_19 + ) subq_20 + WHERE subq_20.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_21 + ) subq_22 + ) subq_23 +) subq_24 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 2691ca3c38..71a7d98121 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_17.bookings) AS bookings - , MAX(subq_23.listings) AS listings + MAX(subq_30.bookings) AS bookings + , MAX(subq_36.listings) AS listings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -11,9 +11,9 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_17 +) subq_30 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -23,6 +23,6 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_23 +) subq_36 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql index f8e4a004b6..8749965e29 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql @@ -1,241 +1,241 @@ -- Compute Metrics via Expressions SELECT - subq_7.user__home_state - , subq_7.identity_verifications + subq_16.user__home_state + , subq_16.identity_verifications FROM ( -- Aggregate Measures SELECT - subq_6.user__home_state - , SUM(subq_6.identity_verifications) AS identity_verifications + subq_15.user__home_state + , SUM(subq_15.identity_verifications) AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'user__home_state'] SELECT - subq_5.user__home_state - , subq_5.identity_verifications + subq_14.user__home_state + , subq_14.identity_verifications FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__day AS user__ds_partitioned__day - , subq_2.user AS user - , subq_4.home_state AS user__home_state - , subq_2.identity_verifications AS identity_verifications + subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__day AS user__ds_partitioned__day + , subq_11.user AS user + , subq_13.home_state AS user__home_state + , subq_11.identity_verifications AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT - subq_1.ds_partitioned__day - , subq_1.user - , subq_1.identity_verifications + subq_10.ds_partitioned__day + , subq_10.user + , subq_10.identity_verifications 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.verification__ds__day - , subq_0.verification__ds__week - , subq_0.verification__ds__month - , subq_0.verification__ds__quarter - , subq_0.verification__ds__year - , subq_0.verification__ds__extract_year - , subq_0.verification__ds__extract_quarter - , subq_0.verification__ds__extract_month - , subq_0.verification__ds__extract_day - , subq_0.verification__ds__extract_dow - , subq_0.verification__ds__extract_doy - , subq_0.verification__ds_partitioned__day - , subq_0.verification__ds_partitioned__week - , subq_0.verification__ds_partitioned__month - , subq_0.verification__ds_partitioned__quarter - , subq_0.verification__ds_partitioned__year - , subq_0.verification__ds_partitioned__extract_year - , subq_0.verification__ds_partitioned__extract_quarter - , subq_0.verification__ds_partitioned__extract_month - , subq_0.verification__ds_partitioned__extract_day - , subq_0.verification__ds_partitioned__extract_dow - , subq_0.verification__ds_partitioned__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.verification - , subq_0.user - , subq_0.verification__user - , subq_0.verification_type - , subq_0.verification__verification_type - , subq_0.identity_verifications + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.verification__ds__day + , subq_9.verification__ds__week + , subq_9.verification__ds__month + , subq_9.verification__ds__quarter + , subq_9.verification__ds__year + , subq_9.verification__ds__extract_year + , subq_9.verification__ds__extract_quarter + , subq_9.verification__ds__extract_month + , subq_9.verification__ds__extract_day + , subq_9.verification__ds__extract_dow + , subq_9.verification__ds__extract_doy + , subq_9.verification__ds_partitioned__day + , subq_9.verification__ds_partitioned__week + , subq_9.verification__ds_partitioned__month + , subq_9.verification__ds_partitioned__quarter + , subq_9.verification__ds_partitioned__year + , subq_9.verification__ds_partitioned__extract_year + , subq_9.verification__ds_partitioned__extract_quarter + , subq_9.verification__ds_partitioned__extract_month + , subq_9.verification__ds_partitioned__extract_day + , subq_9.verification__ds_partitioned__extract_dow + , subq_9.verification__ds_partitioned__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.verification + , subq_9.user + , subq_9.verification__user + , subq_9.verification_type + , subq_9.verification__verification_type + , subq_9.identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(isodow FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user - FROM ***************************.fct_id_verifications id_verifications_src_28004 - ) subq_0 - ) subq_1 - ) subq_2 + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(isodow FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user + FROM ***************************.fct_id_verifications id_verifications_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state', 'ds_partitioned__day', 'user'] SELECT - subq_3.ds_partitioned__day - , subq_3.user - , subq_3.home_state + subq_12.ds_partitioned__day + , subq_12.user + , subq_12.home_state FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - DATE_TRUNC('day', users_ds_source_src_28008.ds) AS ds__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds) AS ds__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds) AS ds__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds) AS ds__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds) AS ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS ds__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28008.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds) AS ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.created_at) AS created_at__day - , DATE_TRUNC('week', users_ds_source_src_28008.created_at) AS created_at__week - , DATE_TRUNC('month', users_ds_source_src_28008.created_at) AS created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.created_at) AS created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.created_at) AS created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28008.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.created_at) AS created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state - , DATE_TRUNC('day', users_ds_source_src_28008.ds) AS user__ds__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds) AS user__ds__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds) AS user__ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS user__ds__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28008.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds) AS user__ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.created_at) AS user__created_at__day - , DATE_TRUNC('week', users_ds_source_src_28008.created_at) AS user__created_at__week - , DATE_TRUNC('month', users_ds_source_src_28008.created_at) AS user__created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.created_at) AS user__created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.created_at) AS user__created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state AS user__home_state - , users_ds_source_src_28008.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28008 - ) subq_3 - ) subq_4 + DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_12 + ) subq_13 ON ( - subq_2.user = subq_4.user + subq_11.user = subq_13.user ) AND ( - subq_2.ds_partitioned__day = subq_4.ds_partitioned__day + subq_11.ds_partitioned__day = subq_13.ds_partitioned__day ) - ) subq_5 - ) subq_6 + ) subq_14 + ) subq_15 GROUP BY - subq_6.user__home_state -) subq_7 + subq_15.user__home_state +) subq_16 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql index 9f15f9bb3d..54ea641813 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql @@ -3,8 +3,8 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - users_ds_source_src_28008.home_state AS user__home_state - , SUM(subq_10.identity_verifications) AS identity_verifications + users_ds_source_src_28000.home_state AS user__home_state + , SUM(subq_19.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' -- Metric Time Dimension 'ds' @@ -13,15 +13,15 @@ FROM ( DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications - FROM ***************************.fct_id_verifications id_verifications_src_28004 -) subq_10 + FROM ***************************.fct_id_verifications id_verifications_src_28000 +) subq_19 LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_28008 + ***************************.dim_users users_ds_source_src_28000 ON ( - subq_10.user = users_ds_source_src_28008.user_id + subq_19.user = users_ds_source_src_28000.user_id ) AND ( - subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) + subq_19.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) ) GROUP BY - users_ds_source_src_28008.home_state + users_ds_source_src_28000.home_state diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0.sql index 9f9ae05e28..cd140b4323 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0.sql @@ -1,439 +1,439 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_value) AS booking_value + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 -) subq_4 + subq_11.metric_time__day + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_value) AS booking_value + subq_16.metric_time__day + , SUM(subq_16.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_value + subq_15.metric_time__day + , subq_15.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_16.metric_time__day + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0_optimized.sql index ccc0d8cd89..7831d40fe6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql index 4de43d5069..cf9f152551 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql @@ -68,62 +68,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0_optimized.sql index 22b719da85..1653ada5bd 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_3 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql index 34c747f02c..a02359b40f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -1,383 +1,383 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_19.booking__is_instant + , subq_19.bookings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_18.booking__is_instant + , SUM(subq_18.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_17.booking__is_instant + , subq_17.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_16.booking__is_instant + , subq_16.listing__country_latest + , subq_16.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.booking__is_instant + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.listing + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__country_latest = 'us' - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_18.booking__is_instant +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index fdbb61ce0e..433c9799b5 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.country AS listing__country_latest - , subq_13.bookings AS bookings + subq_22.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.country AS listing__country_latest + , subq_22.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -20,13 +20,13 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28005.listing_id -) subq_18 + subq_22.listing = listings_latest_src_28000.listing_id +) subq_27 WHERE listing__country_latest = 'us' GROUP BY booking__is_instant diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql index 4f5a80d623..e12a691d4a 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql @@ -1,139 +1,139 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS family_bookings + subq_11.metric_time__day + , subq_11.bookings AS family_bookings FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_10.metric_time__day + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.listing__capacity - , subq_6.bookings + subq_8.metric_time__day + , subq_8.listing__capacity + , subq_8.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.listing__capacity - , subq_5.bookings + subq_7.metric_time__day + , subq_7.listing__capacity + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_4.window_start__day AS listing__window_start__day - , subq_4.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_4.capacity AS listing__capacity - , subq_2.bookings AS bookings + subq_4.metric_time__day AS metric_time__day + , subq_6.window_start__day AS listing__window_start__day + , subq_6.window_end__day AS listing__window_end__day + , subq_4.listing AS listing + , subq_6.capacity AS listing__capacity + , subq_4.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_3.metric_time__day + , subq_3.listing + , subq_3.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + 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.user + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.booking__user + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.bookers + , subq_2.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -220,94 +220,94 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_2 + ) subq_3 + ) subq_4 LEFT OUTER JOIN ( -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_3.window_start__day - , subq_3.window_end__day - , subq_3.listing - , subq_3.capacity + subq_5.window_start__day + , subq_5.window_end__day + , subq_5.listing + , subq_5.capacity FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_26002.active_from) = 0 THEN EXTRACT(dow FROM listings_src_26002.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_26002.active_from) END AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_26002.active_to) = 0 THEN EXTRACT(dow FROM listings_src_26002.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_26002.active_to) END AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_26002.active_from) = 0 THEN EXTRACT(dow FROM listings_src_26002.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_26002.active_from) END AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_26002.active_to) = 0 THEN EXTRACT(dow FROM listings_src_26002.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_26002.active_to) END AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 - ) subq_4 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_26000.active_from) = 0 THEN EXTRACT(dow FROM listings_src_26000.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_26000.active_from) END AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_26000.active_to) = 0 THEN EXTRACT(dow FROM listings_src_26000.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_26000.active_to) END AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_26000.active_from) = 0 THEN EXTRACT(dow FROM listings_src_26000.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_26000.active_from) END AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_26000.active_to) = 0 THEN EXTRACT(dow FROM listings_src_26000.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_26000.active_to) END AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_4.listing + subq_4.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_4.window_start__day + subq_4.metric_time__day >= subq_6.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_4.window_end__day + subq_4.metric_time__day < subq_6.window_end__day ) OR ( - subq_4.window_end__day IS NULL + subq_6.window_end__day IS NULL ) ) ) - ) subq_5 - ) subq_6 + ) subq_7 + ) subq_8 WHERE listing__capacity > 2 - ) subq_7 - ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_8.metric_time__day -) subq_9 + subq_10.metric_time__day +) subq_11 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql index fc848091b1..0f3bd95cd6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_12.metric_time__day AS metric_time__day - , listings_src_26002.capacity AS listing__capacity - , subq_12.bookings AS bookings + subq_14.metric_time__day AS metric_time__day + , listings_src_26000.capacity AS listing__capacity + , subq_14.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -21,24 +21,24 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_12 + ) subq_14 LEFT OUTER JOIN - ***************************.dim_listings listings_src_26002 + ***************************.dim_listings listings_src_26000 ON ( - subq_12.listing = listings_src_26002.listing_id + subq_14.listing = listings_src_26000.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_26002.active_from + subq_14.metric_time__day >= listings_src_26000.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_26002.active_to + subq_14.metric_time__day < listings_src_26000.active_to ) OR ( - listings_src_26002.active_to IS NULL + listings_src_26000.active_to IS NULL ) ) ) -) subq_16 +) subq_18 WHERE listing__capacity > 2 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_limit_rows__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_limit_rows__plan0.sql index 641c2f16d6..72f64cc102 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_limit_rows__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_limit_rows__plan0.sql @@ -1,220 +1,220 @@ -- Order By [] Limit 1 SELECT - subq_4.ds__day - , subq_4.bookings + subq_13.ds__day + , subq_13.bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.bookings + subq_12.ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.bookings + subq_10.ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__day - ) subq_3 -) subq_4 + subq_11.ds__day + ) subq_12 +) subq_13 LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_limit_rows__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_limit_rows__plan0_optimized.sql index a71f7ae0e8..0780ad9c07 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_limit_rows__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_limit_rows__plan0_optimized.sql @@ -11,8 +11,8 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_7 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_16 GROUP BY ds__day LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0.sql index e233020779..506f41e202 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0.sql @@ -1,150 +1,150 @@ -- Compute Metrics via Expressions SELECT - subq_3.listing__country_latest - , subq_3.listings + subq_12.listing__country_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_2.listing__country_latest - , SUM(subq_2.listings) AS listings + subq_11.listing__country_latest + , SUM(subq_11.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'listing__country_latest'] SELECT - subq_1.listing__country_latest - , subq_1.listings + subq_10.listing__country_latest + , subq_10.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.created_at__day - , subq_0.created_at__week - , subq_0.created_at__month - , subq_0.created_at__quarter - , subq_0.created_at__year - , subq_0.created_at__extract_year - , subq_0.created_at__extract_quarter - , subq_0.created_at__extract_month - , subq_0.created_at__extract_day - , subq_0.created_at__extract_dow - , subq_0.created_at__extract_doy - , subq_0.listing__ds__day - , subq_0.listing__ds__week - , subq_0.listing__ds__month - , subq_0.listing__ds__quarter - , subq_0.listing__ds__year - , subq_0.listing__ds__extract_year - , subq_0.listing__ds__extract_quarter - , subq_0.listing__ds__extract_month - , subq_0.listing__ds__extract_day - , subq_0.listing__ds__extract_dow - , subq_0.listing__ds__extract_doy - , subq_0.listing__created_at__day - , subq_0.listing__created_at__week - , subq_0.listing__created_at__month - , subq_0.listing__created_at__quarter - , subq_0.listing__created_at__year - , subq_0.listing__created_at__extract_year - , subq_0.listing__created_at__extract_quarter - , subq_0.listing__created_at__extract_month - , subq_0.listing__created_at__extract_day - , subq_0.listing__created_at__extract_dow - , subq_0.listing__created_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.user - , subq_0.listing__user - , subq_0.country_latest - , subq_0.is_lux_latest - , subq_0.capacity_latest - , subq_0.listing__country_latest - , subq_0.listing__is_lux_latest - , subq_0.listing__capacity_latest - , subq_0.listings - , subq_0.largest_listing - , subq_0.smallest_listing + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.listing__country_latest -) subq_3 + subq_11.listing__country_latest +) subq_12 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0_optimized.sql index 8486e86449..c0733d39a6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT country AS listing__country_latest , 1 AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_6 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_15 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql index f70a5bfcb6..f41933eccb 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql @@ -1,1003 +1,1003 @@ -- Compute Metrics via Expressions SELECT - subq_29.metric_time__day + subq_38.metric_time__day , average_booking_value * bookings / NULLIF(booking_value, 0) AS lux_booking_value_rate_expr FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_28.booking_value) AS booking_value + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_37.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_19.metric_time__day + , subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , AVG(subq_9.average_booking_value) AS average_booking_value + subq_18.metric_time__day + , AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_17.metric_time__day + , subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.metric_time__day + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.metric_time__day + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.average_booking_value AS average_booking_value + subq_11.metric_time__day AS metric_time__day + , subq_11.listing AS listing + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.average_booking_value + subq_10.metric_time__day + , subq_10.listing + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_18.metric_time__day + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day - , subq_22.bookings + subq_31.metric_time__day + , subq_31.bookings FROM ( -- Aggregate Measures SELECT - subq_21.metric_time__day - , SUM(subq_21.bookings) AS bookings + subq_30.metric_time__day + , SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.metric_time__day + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.metric_time__day + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.metric_time__day AS metric_time__day + , subq_23.listing AS listing + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.bookings + subq_22.metric_time__day + , subq_22.listing + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE listing__is_lux_latest - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 GROUP BY - subq_21.metric_time__day - ) subq_22 - ) subq_23 + subq_30.metric_time__day + ) subq_31 + ) subq_32 ON - subq_11.metric_time__day = subq_23.metric_time__day + subq_20.metric_time__day = subq_32.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.booking_value + subq_36.metric_time__day + , subq_36.booking_value FROM ( -- Aggregate Measures SELECT - subq_26.metric_time__day - , SUM(subq_26.booking_value) AS booking_value + subq_35.metric_time__day + , SUM(subq_35.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_25.metric_time__day - , subq_25.booking_value + subq_34.metric_time__day + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 GROUP BY - subq_26.metric_time__day - ) subq_27 - ) subq_28 + subq_35.metric_time__day + ) subq_36 + ) subq_37 ON - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day) = subq_37.metric_time__day GROUP BY - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) -) subq_29 + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day, subq_37.metric_time__day) +) subq_38 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql index 69ba3892a2..91ab825138 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) AS metric_time__day - , MAX(subq_41.average_booking_value) AS average_booking_value - , MAX(subq_53.bookings) AS bookings - , MAX(subq_58.booking_value) AS booking_value + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day, subq_67.metric_time__day) AS metric_time__day + , MAX(subq_50.average_booking_value) AS average_booking_value + , MAX(subq_62.bookings) AS bookings + , MAX(subq_67.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -21,19 +21,19 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - DATE_TRUNC('day', bookings_source_src_28001.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + DATE_TRUNC('day', bookings_source_src_28000.ds) AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_37 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_46 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_41 + ) subq_50 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -46,9 +46,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_44.metric_time__day AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_44.bookings AS bookings + subq_53.metric_time__day AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_53.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -57,19 +57,19 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_44 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_53 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_44.listing = listings_latest_src_28005.listing_id - ) subq_49 + subq_53.listing = listings_latest_src_28000.listing_id + ) subq_58 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_53 + ) subq_62 ON - subq_41.metric_time__day = subq_53.metric_time__day + subq_50.metric_time__day = subq_62.metric_time__day FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -79,12 +79,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_58 + ) subq_67 ON - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day) = subq_58.metric_time__day + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day) = subq_67.metric_time__day GROUP BY - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) -) subq_59 + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day, subq_67.metric_time__day) +) subq_68 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql index 83369d2e19..a8ba888b8b 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,460 +1,460 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , CAST(subq_12.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_12.booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio + subq_21.metric_time__day + , CAST(subq_21.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_21.booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , MAX(subq_6.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_11.booking_value) AS booking_value + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day + , MAX(subq_15.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_20.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.booking_value AS booking_value_with_is_instant_constraint + subq_14.metric_time__day + , subq_14.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.booking_value) AS booking_value + subq_13.metric_time__day + , SUM(subq_13.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.booking_value + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_13.metric_time__day + ) subq_14 + ) subq_15 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_19.metric_time__day + , subq_19.booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.booking_value) AS booking_value + subq_18.metric_time__day + , SUM(subq_18.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.ds_partitioned__day + , subq_16.ds_partitioned__week + , subq_16.ds_partitioned__month + , subq_16.ds_partitioned__quarter + , subq_16.ds_partitioned__year + , subq_16.ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy + , subq_16.paid_at__day + , subq_16.paid_at__week + , subq_16.paid_at__month + , subq_16.paid_at__quarter + , subq_16.paid_at__year + , subq_16.paid_at__extract_year + , subq_16.paid_at__extract_quarter + , subq_16.paid_at__extract_month + , subq_16.paid_at__extract_day + , subq_16.paid_at__extract_dow + , subq_16.paid_at__extract_doy + , subq_16.booking__ds__day + , subq_16.booking__ds__week + , subq_16.booking__ds__month + , subq_16.booking__ds__quarter + , subq_16.booking__ds__year + , subq_16.booking__ds__extract_year + , subq_16.booking__ds__extract_quarter + , subq_16.booking__ds__extract_month + , subq_16.booking__ds__extract_day + , subq_16.booking__ds__extract_dow + , subq_16.booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day + , subq_16.booking__paid_at__week + , subq_16.booking__paid_at__month + , subq_16.booking__paid_at__quarter + , subq_16.booking__paid_at__year + , subq_16.booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.listing + , subq_16.guest + , subq_16.host + , subq_16.booking__listing + , subq_16.booking__guest + , subq_16.booking__host + , subq_16.is_instant + , subq_16.booking__is_instant + , subq_16.bookings + , subq_16.instant_bookings + , subq_16.booking_value + , subq_16.max_booking_value + , subq_16.min_booking_value + , subq_16.bookers + , subq_16.average_booking_value + , subq_16.referred_bookings + , subq_16.median_booking_value + , subq_16.booking_value_p99 + , subq_16.discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 + , subq_16.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_7 - ) subq_8 - ) subq_9 + , 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_16 + ) subq_17 + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_18.metric_time__day + ) subq_19 + ) subq_20 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_15.metric_time__day = subq_20.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) +) subq_21 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql index bc8639fea2..d0df93a404 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/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_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , MAX(subq_19.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_24.booking_value) AS booking_value + COALESCE(subq_28.metric_time__day, subq_33.metric_time__day) AS metric_time__day + , MAX(subq_28.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_33.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_28 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -39,12 +39,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_33 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_28.metric_time__day = subq_33.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_28.metric_time__day, subq_33.metric_time__day) +) subq_34 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql index b39aae10e1..c88503868c 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,234 +1,234 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day + subq_15.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.bookings AS delayed_bookings + subq_14.metric_time__day + , subq_14.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_13.metric_time__day + , SUM(subq_13.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE NOT booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY - subq_4.metric_time__day - ) subq_5 -) subq_6 + subq_13.metric_time__day + ) subq_14 +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index df414b0013..c494772d25 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -18,9 +18,9 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 799b2601de..84471357c8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -1,366 +1,366 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_10.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_10.listings, 0) AS DOUBLE PRECISION) AS bookings_per_listing + CAST(subq_19.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_19.listings, 0) AS DOUBLE PRECISION) AS bookings_per_listing FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_4.bookings) AS bookings - , MAX(subq_9.listings) AS listings + MAX(subq_13.bookings) AS bookings + , MAX(subq_18.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.bookings + subq_12.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_2.bookings) AS bookings + SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_1.bookings + subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 - ) subq_4 + , 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_9 + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.listings + subq_17.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_7.listings) AS listings + SUM(subq_16.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_6.listings + subq_15.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.created_at__day - , subq_5.created_at__week - , subq_5.created_at__month - , subq_5.created_at__quarter - , subq_5.created_at__year - , subq_5.created_at__extract_year - , subq_5.created_at__extract_quarter - , subq_5.created_at__extract_month - , subq_5.created_at__extract_day - , subq_5.created_at__extract_dow - , subq_5.created_at__extract_doy - , subq_5.listing__ds__day - , subq_5.listing__ds__week - , subq_5.listing__ds__month - , subq_5.listing__ds__quarter - , subq_5.listing__ds__year - , subq_5.listing__ds__extract_year - , subq_5.listing__ds__extract_quarter - , subq_5.listing__ds__extract_month - , subq_5.listing__ds__extract_day - , subq_5.listing__ds__extract_dow - , subq_5.listing__ds__extract_doy - , subq_5.listing__created_at__day - , subq_5.listing__created_at__week - , subq_5.listing__created_at__month - , subq_5.listing__created_at__quarter - , subq_5.listing__created_at__year - , subq_5.listing__created_at__extract_year - , subq_5.listing__created_at__extract_quarter - , subq_5.listing__created_at__extract_month - , subq_5.listing__created_at__extract_day - , subq_5.listing__created_at__extract_dow - , subq_5.listing__created_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.user - , subq_5.listing__user - , subq_5.country_latest - , subq_5.is_lux_latest - , subq_5.capacity_latest - , subq_5.listing__country_latest - , subq_5.listing__is_lux_latest - , subq_5.listing__capacity_latest - , subq_5.listings - , subq_5.largest_listing - , subq_5.smallest_listing + 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.created_at__day + , subq_14.created_at__week + , subq_14.created_at__month + , subq_14.created_at__quarter + , subq_14.created_at__year + , subq_14.created_at__extract_year + , subq_14.created_at__extract_quarter + , subq_14.created_at__extract_month + , subq_14.created_at__extract_day + , subq_14.created_at__extract_dow + , subq_14.created_at__extract_doy + , subq_14.listing__ds__day + , subq_14.listing__ds__week + , subq_14.listing__ds__month + , subq_14.listing__ds__quarter + , subq_14.listing__ds__year + , subq_14.listing__ds__extract_year + , subq_14.listing__ds__extract_quarter + , subq_14.listing__ds__extract_month + , subq_14.listing__ds__extract_day + , subq_14.listing__ds__extract_dow + , subq_14.listing__ds__extract_doy + , subq_14.listing__created_at__day + , subq_14.listing__created_at__week + , subq_14.listing__created_at__month + , subq_14.listing__created_at__quarter + , subq_14.listing__created_at__year + , subq_14.listing__created_at__extract_year + , subq_14.listing__created_at__extract_quarter + , subq_14.listing__created_at__extract_month + , subq_14.listing__created_at__extract_day + , subq_14.listing__created_at__extract_dow + , subq_14.listing__created_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.user + , subq_14.listing__user + , subq_14.country_latest + , subq_14.is_lux_latest + , subq_14.capacity_latest + , subq_14.listing__country_latest + , subq_14.listing__is_lux_latest + , subq_14.listing__capacity_latest + , subq_14.listings + , subq_14.largest_listing + , subq_14.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_5 - ) subq_6 - ) subq_7 - ) subq_8 - ) subq_9 -) subq_10 + , 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_14 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index 201c81c126..a2c5f08fc7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_15.bookings) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_20.listings), 0) AS DOUBLE PRECISION) AS bookings_per_listing + CAST(MAX(subq_24.bookings) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_29.listings), 0) AS DOUBLE PRECISION) AS bookings_per_listing FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -10,8 +10,8 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_24 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -20,5 +20,5 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_20 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_29 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_categorical__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_categorical__plan0.sql index b0c482aaa1..979511b896 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_categorical__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_categorical__plan0.sql @@ -10,62 +10,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 GROUP BY subq_0.listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_categorical__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_categorical__plan0_optimized.sql index c1da0c0382..a8d1afa6a8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_categorical__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_categorical__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 GROUP BY country ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time__plan0.sql index a66e06cc63..19569e03f1 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY subq_0.booking__paid_at__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time__plan0_optimized.sql index 280b915894..e6a861c58f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__day',] SELECT DATE_TRUNC('day', paid_at) AS booking__paid_at__day - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', paid_at) ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time_quarter__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time_quarter__plan0.sql index 37667b848c..a359ddc666 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time_quarter__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time_quarter__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY subq_0.booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time_quarter__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time_quarter__plan0_optimized.sql index f6d583edbe..5ff0fa4feb 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time_quarter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_min_max_only_time_quarter__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__quarter',] SELECT DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('quarter', paid_at) ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql index 3b8dc1a9ee..51e6e23e1e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__user__home_state_latest - , subq_10.bookings + subq_23.metric_time__day + , subq_23.listing__user__home_state_latest + , subq_23.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest - , SUM(subq_9.bookings) AS bookings + subq_22.metric_time__day + , subq_22.listing__user__home_state_latest + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__home_state_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__user__home_state_latest - , subq_8.bookings + subq_21.metric_time__day + , subq_21.listing__user__home_state_latest + , subq_21.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.window_start__day AS listing__window_start__day - , subq_7.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_7.user__home_state_latest AS listing__user__home_state_latest - , subq_2.bookings AS bookings + subq_15.metric_time__day AS metric_time__day + , subq_20.window_start__day AS listing__window_start__day + , subq_20.window_end__day AS listing__window_end__day + , subq_15.listing AS listing + , subq_20.user__home_state_latest AS listing__user__home_state_latest + , subq_15.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_14.metric_time__day + , subq_14.listing + , subq_14.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.user + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.booking__user + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.bookers + , subq_13.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,142 +211,142 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_13 + ) subq_14 + ) subq_15 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_6.window_start__day - , subq_6.window_end__day - , subq_6.listing - , subq_6.user__home_state_latest + subq_19.window_start__day + , subq_19.window_end__day + , subq_19.listing + , subq_19.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_3.window_start__day AS window_start__day - , subq_3.window_start__week AS window_start__week - , subq_3.window_start__month AS window_start__month - , subq_3.window_start__quarter AS window_start__quarter - , subq_3.window_start__year AS window_start__year - , subq_3.window_start__extract_year AS window_start__extract_year - , subq_3.window_start__extract_quarter AS window_start__extract_quarter - , subq_3.window_start__extract_month AS window_start__extract_month - , subq_3.window_start__extract_day AS window_start__extract_day - , subq_3.window_start__extract_dow AS window_start__extract_dow - , subq_3.window_start__extract_doy AS window_start__extract_doy - , subq_3.window_end__day AS window_end__day - , subq_3.window_end__week AS window_end__week - , subq_3.window_end__month AS window_end__month - , subq_3.window_end__quarter AS window_end__quarter - , subq_3.window_end__year AS window_end__year - , subq_3.window_end__extract_year AS window_end__extract_year - , subq_3.window_end__extract_quarter AS window_end__extract_quarter - , subq_3.window_end__extract_month AS window_end__extract_month - , subq_3.window_end__extract_day AS window_end__extract_day - , subq_3.window_end__extract_dow AS window_end__extract_dow - , subq_3.window_end__extract_doy AS window_end__extract_doy - , subq_3.listing__window_start__day AS listing__window_start__day - , subq_3.listing__window_start__week AS listing__window_start__week - , subq_3.listing__window_start__month AS listing__window_start__month - , subq_3.listing__window_start__quarter AS listing__window_start__quarter - , subq_3.listing__window_start__year AS listing__window_start__year - , subq_3.listing__window_start__extract_year AS listing__window_start__extract_year - , subq_3.listing__window_start__extract_quarter AS listing__window_start__extract_quarter - , subq_3.listing__window_start__extract_month AS listing__window_start__extract_month - , subq_3.listing__window_start__extract_day AS listing__window_start__extract_day - , subq_3.listing__window_start__extract_dow AS listing__window_start__extract_dow - , subq_3.listing__window_start__extract_doy AS listing__window_start__extract_doy - , subq_3.listing__window_end__day AS listing__window_end__day - , subq_3.listing__window_end__week AS listing__window_end__week - , subq_3.listing__window_end__month AS listing__window_end__month - , subq_3.listing__window_end__quarter AS listing__window_end__quarter - , subq_3.listing__window_end__year AS listing__window_end__year - , subq_3.listing__window_end__extract_year AS listing__window_end__extract_year - , subq_3.listing__window_end__extract_quarter AS listing__window_end__extract_quarter - , subq_3.listing__window_end__extract_month AS listing__window_end__extract_month - , subq_3.listing__window_end__extract_day AS listing__window_end__extract_day - , subq_3.listing__window_end__extract_dow AS listing__window_end__extract_dow - , subq_3.listing__window_end__extract_doy AS listing__window_end__extract_doy - , subq_5.ds__day AS user__ds__day - , subq_5.ds__week AS user__ds__week - , subq_5.ds__month AS user__ds__month - , subq_5.ds__quarter AS user__ds__quarter - , subq_5.ds__year AS user__ds__year - , subq_5.ds__extract_year AS user__ds__extract_year - , subq_5.ds__extract_quarter AS user__ds__extract_quarter - , subq_5.ds__extract_month AS user__ds__extract_month - , subq_5.ds__extract_day AS user__ds__extract_day - , subq_5.ds__extract_dow AS user__ds__extract_dow - , subq_5.ds__extract_doy AS user__ds__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country AS country - , subq_3.is_lux AS is_lux - , subq_3.capacity AS capacity - , subq_3.listing__country AS listing__country - , subq_3.listing__is_lux AS listing__is_lux - , subq_3.listing__capacity AS listing__capacity - , subq_5.home_state_latest AS user__home_state_latest + subq_16.window_start__day AS window_start__day + , subq_16.window_start__week AS window_start__week + , subq_16.window_start__month AS window_start__month + , subq_16.window_start__quarter AS window_start__quarter + , subq_16.window_start__year AS window_start__year + , subq_16.window_start__extract_year AS window_start__extract_year + , subq_16.window_start__extract_quarter AS window_start__extract_quarter + , subq_16.window_start__extract_month AS window_start__extract_month + , subq_16.window_start__extract_day AS window_start__extract_day + , subq_16.window_start__extract_dow AS window_start__extract_dow + , subq_16.window_start__extract_doy AS window_start__extract_doy + , subq_16.window_end__day AS window_end__day + , subq_16.window_end__week AS window_end__week + , subq_16.window_end__month AS window_end__month + , subq_16.window_end__quarter AS window_end__quarter + , subq_16.window_end__year AS window_end__year + , subq_16.window_end__extract_year AS window_end__extract_year + , subq_16.window_end__extract_quarter AS window_end__extract_quarter + , subq_16.window_end__extract_month AS window_end__extract_month + , subq_16.window_end__extract_day AS window_end__extract_day + , subq_16.window_end__extract_dow AS window_end__extract_dow + , subq_16.window_end__extract_doy AS window_end__extract_doy + , subq_16.listing__window_start__day AS listing__window_start__day + , subq_16.listing__window_start__week AS listing__window_start__week + , subq_16.listing__window_start__month AS listing__window_start__month + , subq_16.listing__window_start__quarter AS listing__window_start__quarter + , subq_16.listing__window_start__year AS listing__window_start__year + , subq_16.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_16.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_16.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_16.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_16.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_16.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_16.listing__window_end__day AS listing__window_end__day + , subq_16.listing__window_end__week AS listing__window_end__week + , subq_16.listing__window_end__month AS listing__window_end__month + , subq_16.listing__window_end__quarter AS listing__window_end__quarter + , subq_16.listing__window_end__year AS listing__window_end__year + , subq_16.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_16.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_16.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_16.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_16.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_16.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_18.ds__day AS user__ds__day + , subq_18.ds__week AS user__ds__week + , subq_18.ds__month AS user__ds__month + , subq_18.ds__quarter AS user__ds__quarter + , subq_18.ds__year AS user__ds__year + , subq_18.ds__extract_year AS user__ds__extract_year + , subq_18.ds__extract_quarter AS user__ds__extract_quarter + , subq_18.ds__extract_month AS user__ds__extract_month + , subq_18.ds__extract_day AS user__ds__extract_day + , subq_18.ds__extract_dow AS user__ds__extract_dow + , subq_18.ds__extract_doy AS user__ds__extract_doy + , subq_16.listing AS listing + , subq_16.user AS user + , subq_16.listing__user AS listing__user + , subq_16.country AS country + , subq_16.is_lux AS is_lux + , subq_16.capacity AS capacity + , subq_16.listing__country AS listing__country + , subq_16.listing__is_lux AS listing__is_lux + , subq_16.listing__capacity AS listing__capacity + , subq_18.home_state_latest AS user__home_state_latest FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_26002.active_from) = 0 THEN EXTRACT(dow FROM listings_src_26002.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_26002.active_from) END AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_26002.active_to) = 0 THEN EXTRACT(dow FROM listings_src_26002.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_26002.active_to) END AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_26002.active_from) = 0 THEN EXTRACT(dow FROM listings_src_26002.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_26002.active_from) END AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , CASE WHEN EXTRACT(dow FROM listings_src_26002.active_to) = 0 THEN EXTRACT(dow FROM listings_src_26002.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_26002.active_to) END AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_26000.active_from) = 0 THEN EXTRACT(dow FROM listings_src_26000.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_26000.active_from) END AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_26000.active_to) = 0 THEN EXTRACT(dow FROM listings_src_26000.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_26000.active_to) END AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_26000.active_from) = 0 THEN EXTRACT(dow FROM listings_src_26000.active_from) + 7 ELSE EXTRACT(dow FROM listings_src_26000.active_from) END AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , CASE WHEN EXTRACT(dow FROM listings_src_26000.active_to) = 0 THEN EXTRACT(dow FROM listings_src_26000.active_to) + 7 ELSE EXTRACT(dow FROM listings_src_26000.active_to) END AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_16 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,83 +376,83 @@ FROM ( -- 'user', -- ] SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.user__ds__day - , subq_4.user__ds__week - , subq_4.user__ds__month - , subq_4.user__ds__quarter - , subq_4.user__ds__year - , subq_4.user__ds__extract_year - , subq_4.user__ds__extract_quarter - , subq_4.user__ds__extract_month - , subq_4.user__ds__extract_day - , subq_4.user__ds__extract_dow - , subq_4.user__ds__extract_doy - , subq_4.user - , subq_4.home_state_latest - , subq_4.user__home_state_latest + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.user__ds__day + , subq_17.user__ds__week + , subq_17.user__ds__month + , subq_17.user__ds__quarter + , subq_17.user__ds__year + , subq_17.user__ds__extract_year + , subq_17.user__ds__extract_quarter + , subq_17.user__ds__extract_month + , subq_17.user__ds__extract_day + , subq_17.user__ds__extract_dow + , subq_17.user__ds__extract_doy + , subq_17.user + , subq_17.home_state_latest + , subq_17.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_26006.ds) AS ds__day - , DATE_TRUNC('week', users_latest_src_26006.ds) AS ds__week - , DATE_TRUNC('month', users_latest_src_26006.ds) AS ds__month - , DATE_TRUNC('quarter', users_latest_src_26006.ds) AS ds__quarter - , DATE_TRUNC('year', users_latest_src_26006.ds) AS ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_26006.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_26006.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_26006.ds) END AS ds__extract_dow - , EXTRACT(doy FROM users_latest_src_26006.ds) AS ds__extract_doy - , users_latest_src_26006.home_state_latest - , DATE_TRUNC('day', users_latest_src_26006.ds) AS user__ds__day - , DATE_TRUNC('week', users_latest_src_26006.ds) AS user__ds__week - , DATE_TRUNC('month', users_latest_src_26006.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_latest_src_26006.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_latest_src_26006.ds) AS user__ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS user__ds__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_26006.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_26006.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_26006.ds) END AS user__ds__extract_dow - , EXTRACT(doy FROM users_latest_src_26006.ds) AS user__ds__extract_doy - , users_latest_src_26006.home_state_latest AS user__home_state_latest - , users_latest_src_26006.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_26006 - ) subq_4 - ) subq_5 + DATE_TRUNC('day', users_latest_src_26000.ds) AS ds__day + , DATE_TRUNC('week', users_latest_src_26000.ds) AS ds__week + , DATE_TRUNC('month', users_latest_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', users_latest_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', users_latest_src_26000.ds) AS ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_26000.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_26000.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_26000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM users_latest_src_26000.ds) AS ds__extract_doy + , users_latest_src_26000.home_state_latest + , DATE_TRUNC('day', users_latest_src_26000.ds) AS user__ds__day + , DATE_TRUNC('week', users_latest_src_26000.ds) AS user__ds__week + , DATE_TRUNC('month', users_latest_src_26000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_latest_src_26000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_latest_src_26000.ds) AS user__ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS user__ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_26000.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_26000.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_26000.ds) END AS user__ds__extract_dow + , EXTRACT(doy FROM users_latest_src_26000.ds) AS user__ds__extract_doy + , users_latest_src_26000.home_state_latest AS user__home_state_latest + , users_latest_src_26000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_26000 + ) subq_17 + ) subq_18 ON - subq_3.user = subq_5.user - ) subq_6 - ) subq_7 + subq_16.user = subq_18.user + ) subq_19 + ) subq_20 ON ( - subq_2.listing = subq_7.listing + subq_15.listing = subq_20.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.window_start__day + subq_15.metric_time__day >= subq_20.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.window_end__day + subq_15.metric_time__day < subq_20.window_end__day ) OR ( - subq_7.window_end__day IS NULL + subq_20.window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_21 + ) subq_22 GROUP BY - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest -) subq_10 + subq_22.metric_time__day + , subq_22.listing__user__home_state_latest +) subq_23 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 1d7e6c24a7..f38afda4f7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.user__home_state_latest AS listing__user__home_state_latest - , SUM(subq_13.bookings) AS bookings + subq_26.metric_time__day AS metric_time__day + , subq_31.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_26.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,35 +15,35 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_26 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - listings_src_26002.active_from AS window_start__day - , listings_src_26002.active_to AS window_end__day - , listings_src_26002.listing_id AS listing - , users_latest_src_26006.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings listings_src_26002 + listings_src_26000.active_from AS window_start__day + , listings_src_26000.active_to AS window_end__day + , listings_src_26000.listing_id AS listing + , users_latest_src_26000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings listings_src_26000 LEFT OUTER JOIN - ***************************.dim_users_latest users_latest_src_26006 + ***************************.dim_users_latest users_latest_src_26000 ON - listings_src_26002.user_id = users_latest_src_26006.user_id -) subq_18 + listings_src_26000.user_id = users_latest_src_26000.user_id +) subq_31 ON ( - subq_13.listing = subq_18.listing + subq_26.listing = subq_31.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_26.metric_time__day >= subq_31.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_26.metric_time__day < subq_31.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_31.window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.user__home_state_latest + subq_26.metric_time__day + , subq_31.user__home_state_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql index 36efbb0f7b..56476c940c 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__lux_listing__is_confirmed_lux - , subq_10.bookings + subq_15.metric_time__day + , subq_15.listing__lux_listing__is_confirmed_lux + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux - , SUM(subq_9.bookings) AS bookings + subq_14.metric_time__day + , subq_14.listing__lux_listing__is_confirmed_lux + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__lux_listing__is_confirmed_lux', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__lux_listing__is_confirmed_lux - , subq_8.bookings + subq_13.metric_time__day + , subq_13.listing__lux_listing__is_confirmed_lux + , subq_13.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.lux_listing__window_start__day AS listing__lux_listing__window_start__day - , subq_7.lux_listing__window_end__day AS listing__lux_listing__window_end__day - , subq_2.listing AS listing - , subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , subq_2.bookings AS bookings + subq_7.metric_time__day AS metric_time__day + , subq_12.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_12.lux_listing__window_end__day AS listing__lux_listing__window_end__day + , subq_7.listing AS listing + , subq_12.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_7.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_6.metric_time__day + , subq_6.listing + , subq_6.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.ds__day AS metric_time__day + , subq_5.ds__week AS metric_time__week + , subq_5.ds__month AS metric_time__month + , subq_5.ds__quarter AS metric_time__quarter + , subq_5.ds__year AS metric_time__year + , subq_5.ds__extract_year AS metric_time__extract_year + , subq_5.ds__extract_quarter AS metric_time__extract_quarter + , subq_5.ds__extract_month AS metric_time__extract_month + , subq_5.ds__extract_day AS metric_time__extract_day + , subq_5.ds__extract_dow AS metric_time__extract_dow + , subq_5.ds__extract_doy AS metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.user + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.booking__user + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.bookings + , subq_5.instant_bookings + , subq_5.booking_value + , subq_5.bookers + , subq_5.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,53 +211,53 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_5 + ) subq_6 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - subq_6.lux_listing__window_start__day - , subq_6.lux_listing__window_end__day - , subq_6.listing - , subq_6.lux_listing__is_confirmed_lux + subq_11.lux_listing__window_start__day + , subq_11.lux_listing__window_end__day + , subq_11.listing + , subq_11.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_5.window_start__day AS lux_listing__window_start__day - , subq_5.window_start__week AS lux_listing__window_start__week - , subq_5.window_start__month AS lux_listing__window_start__month - , subq_5.window_start__quarter AS lux_listing__window_start__quarter - , subq_5.window_start__year AS lux_listing__window_start__year - , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_5.window_end__day AS lux_listing__window_end__day - , subq_5.window_end__week AS lux_listing__window_end__week - , subq_5.window_end__month AS lux_listing__window_end__month - , subq_5.window_end__quarter AS lux_listing__window_end__quarter - , subq_5.window_end__year AS lux_listing__window_end__year - , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_3.listing AS listing - , subq_3.lux_listing AS lux_listing - , subq_3.listing__lux_listing AS listing__lux_listing - , subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux + subq_10.window_start__day AS lux_listing__window_start__day + , subq_10.window_start__week AS lux_listing__window_start__week + , subq_10.window_start__month AS lux_listing__window_start__month + , subq_10.window_start__quarter AS lux_listing__window_start__quarter + , subq_10.window_start__year AS lux_listing__window_start__year + , subq_10.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_10.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_10.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_10.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_10.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_10.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_10.window_end__day AS lux_listing__window_end__day + , subq_10.window_end__week AS lux_listing__window_end__week + , subq_10.window_end__month AS lux_listing__window_end__month + , subq_10.window_end__quarter AS lux_listing__window_end__quarter + , subq_10.window_end__year AS lux_listing__window_end__year + , subq_10.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_10.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_10.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_10.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_10.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_10.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_8.listing AS listing + , subq_8.lux_listing AS lux_listing + , subq_8.listing__lux_listing AS listing__lux_listing + , subq_10.is_confirmed_lux AS lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT - lux_listing_mapping_src_26003.listing_id AS listing - , lux_listing_mapping_src_26003.lux_listing_id AS lux_listing - , lux_listing_mapping_src_26003.lux_listing_id AS listing__lux_listing - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 - ) subq_3 + lux_listing_mapping_src_26000.listing_id AS listing + , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing + , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 + ) subq_8 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,127 +309,127 @@ FROM ( -- 'lux_listing', -- ] SELECT - subq_4.window_start__day - , subq_4.window_start__week - , subq_4.window_start__month - , subq_4.window_start__quarter - , subq_4.window_start__year - , subq_4.window_start__extract_year - , subq_4.window_start__extract_quarter - , subq_4.window_start__extract_month - , subq_4.window_start__extract_day - , subq_4.window_start__extract_dow - , subq_4.window_start__extract_doy - , subq_4.window_end__day - , subq_4.window_end__week - , subq_4.window_end__month - , subq_4.window_end__quarter - , subq_4.window_end__year - , subq_4.window_end__extract_year - , subq_4.window_end__extract_quarter - , subq_4.window_end__extract_month - , subq_4.window_end__extract_day - , subq_4.window_end__extract_dow - , subq_4.window_end__extract_doy - , subq_4.lux_listing__window_start__day - , subq_4.lux_listing__window_start__week - , subq_4.lux_listing__window_start__month - , subq_4.lux_listing__window_start__quarter - , subq_4.lux_listing__window_start__year - , subq_4.lux_listing__window_start__extract_year - , subq_4.lux_listing__window_start__extract_quarter - , subq_4.lux_listing__window_start__extract_month - , subq_4.lux_listing__window_start__extract_day - , subq_4.lux_listing__window_start__extract_dow - , subq_4.lux_listing__window_start__extract_doy - , subq_4.lux_listing__window_end__day - , subq_4.lux_listing__window_end__week - , subq_4.lux_listing__window_end__month - , subq_4.lux_listing__window_end__quarter - , subq_4.lux_listing__window_end__year - , subq_4.lux_listing__window_end__extract_year - , subq_4.lux_listing__window_end__extract_quarter - , subq_4.lux_listing__window_end__extract_month - , subq_4.lux_listing__window_end__extract_day - , subq_4.lux_listing__window_end__extract_dow - , subq_4.lux_listing__window_end__extract_doy - , subq_4.lux_listing - , subq_4.is_confirmed_lux - , subq_4.lux_listing__is_confirmed_lux + subq_9.window_start__day + , subq_9.window_start__week + , subq_9.window_start__month + , subq_9.window_start__quarter + , subq_9.window_start__year + , subq_9.window_start__extract_year + , subq_9.window_start__extract_quarter + , subq_9.window_start__extract_month + , subq_9.window_start__extract_day + , subq_9.window_start__extract_dow + , subq_9.window_start__extract_doy + , subq_9.window_end__day + , subq_9.window_end__week + , subq_9.window_end__month + , subq_9.window_end__quarter + , subq_9.window_end__year + , subq_9.window_end__extract_year + , subq_9.window_end__extract_quarter + , subq_9.window_end__extract_month + , subq_9.window_end__extract_day + , subq_9.window_end__extract_dow + , subq_9.window_end__extract_doy + , subq_9.lux_listing__window_start__day + , subq_9.lux_listing__window_start__week + , subq_9.lux_listing__window_start__month + , subq_9.lux_listing__window_start__quarter + , subq_9.lux_listing__window_start__year + , subq_9.lux_listing__window_start__extract_year + , subq_9.lux_listing__window_start__extract_quarter + , subq_9.lux_listing__window_start__extract_month + , subq_9.lux_listing__window_start__extract_day + , subq_9.lux_listing__window_start__extract_dow + , subq_9.lux_listing__window_start__extract_doy + , subq_9.lux_listing__window_end__day + , subq_9.lux_listing__window_end__week + , subq_9.lux_listing__window_end__month + , subq_9.lux_listing__window_end__quarter + , subq_9.lux_listing__window_end__year + , subq_9.lux_listing__window_end__extract_year + , subq_9.lux_listing__window_end__extract_quarter + , subq_9.lux_listing__window_end__extract_month + , subq_9.lux_listing__window_end__extract_day + , subq_9.lux_listing__window_end__extract_dow + , subq_9.lux_listing__window_end__extract_doy + , subq_9.lux_listing + , subq_9.is_confirmed_lux + , subq_9.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT - lux_listings_src_26004.valid_from AS window_start__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_from) AS window_start__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_from) AS window_start__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_from) AS window_start__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_from) AS window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS window_start__extract_day - , CASE WHEN EXTRACT(dow FROM lux_listings_src_26004.valid_from) = 0 THEN EXTRACT(dow FROM lux_listings_src_26004.valid_from) + 7 ELSE EXTRACT(dow FROM lux_listings_src_26004.valid_from) END AS window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_from) AS window_start__extract_doy - , lux_listings_src_26004.valid_to AS window_end__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_to) AS window_end__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_to) AS window_end__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_to) AS window_end__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_to) AS window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS window_end__extract_day - , CASE WHEN EXTRACT(dow FROM lux_listings_src_26004.valid_to) = 0 THEN EXTRACT(dow FROM lux_listings_src_26004.valid_to) + 7 ELSE EXTRACT(dow FROM lux_listings_src_26004.valid_to) END AS window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_to) AS window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux - , lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_from) AS lux_listing__window_start__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_from) AS lux_listing__window_start__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_from) AS lux_listing__window_start__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_from) AS lux_listing__window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_day - , CASE WHEN EXTRACT(dow FROM lux_listings_src_26004.valid_from) = 0 THEN EXTRACT(dow FROM lux_listings_src_26004.valid_from) + 7 ELSE EXTRACT(dow FROM lux_listings_src_26004.valid_from) END AS lux_listing__window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_doy - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_to) AS lux_listing__window_end__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_to) AS lux_listing__window_end__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_to) AS lux_listing__window_end__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_to) AS lux_listing__window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_day - , CASE WHEN EXTRACT(dow FROM lux_listings_src_26004.valid_to) = 0 THEN EXTRACT(dow FROM lux_listings_src_26004.valid_to) + 7 ELSE EXTRACT(dow FROM lux_listings_src_26004.valid_to) END AS lux_listing__window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - , lux_listings_src_26004.lux_listing_id AS lux_listing - FROM ***************************.dim_lux_listings lux_listings_src_26004 - ) subq_4 - ) subq_5 + lux_listings_src_26000.valid_from AS window_start__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_from) AS window_start__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_from) AS window_start__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_from) AS window_start__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_from) AS window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS window_start__extract_day + , CASE WHEN EXTRACT(dow FROM lux_listings_src_26000.valid_from) = 0 THEN EXTRACT(dow FROM lux_listings_src_26000.valid_from) + 7 ELSE EXTRACT(dow FROM lux_listings_src_26000.valid_from) END AS window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_from) AS window_start__extract_doy + , lux_listings_src_26000.valid_to AS window_end__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_to) AS window_end__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_to) AS window_end__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_to) AS window_end__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_to) AS window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS window_end__extract_day + , CASE WHEN EXTRACT(dow FROM lux_listings_src_26000.valid_to) = 0 THEN EXTRACT(dow FROM lux_listings_src_26000.valid_to) + 7 ELSE EXTRACT(dow FROM lux_listings_src_26000.valid_to) END AS window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_to) AS window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux + , lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_from) AS lux_listing__window_start__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_from) AS lux_listing__window_start__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_from) AS lux_listing__window_start__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_from) AS lux_listing__window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_day + , CASE WHEN EXTRACT(dow FROM lux_listings_src_26000.valid_from) = 0 THEN EXTRACT(dow FROM lux_listings_src_26000.valid_from) + 7 ELSE EXTRACT(dow FROM lux_listings_src_26000.valid_from) END AS lux_listing__window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_doy + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_to) AS lux_listing__window_end__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_to) AS lux_listing__window_end__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_to) AS lux_listing__window_end__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_to) AS lux_listing__window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_day + , CASE WHEN EXTRACT(dow FROM lux_listings_src_26000.valid_to) = 0 THEN EXTRACT(dow FROM lux_listings_src_26000.valid_to) + 7 ELSE EXTRACT(dow FROM lux_listings_src_26000.valid_to) END AS lux_listing__window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + , lux_listings_src_26000.lux_listing_id AS lux_listing + FROM ***************************.dim_lux_listings lux_listings_src_26000 + ) subq_9 + ) subq_10 ON - subq_3.lux_listing = subq_5.lux_listing - ) subq_6 - ) subq_7 + subq_8.lux_listing = subq_10.lux_listing + ) subq_11 + ) subq_12 ON ( - subq_2.listing = subq_7.listing + subq_7.listing = subq_12.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.lux_listing__window_start__day + subq_7.metric_time__day >= subq_12.lux_listing__window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.lux_listing__window_end__day + subq_7.metric_time__day < subq_12.lux_listing__window_end__day ) OR ( - subq_7.lux_listing__window_end__day IS NULL + subq_12.lux_listing__window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_13 + ) subq_14 GROUP BY - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux -) subq_10 + subq_14.metric_time__day + , subq_14.listing__lux_listing__is_confirmed_lux +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql index 0ef5f08ffa..eb9b15d13c 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , SUM(subq_13.bookings) AS bookings + subq_18.metric_time__day AS metric_time__day + , subq_23.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_18.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,35 +15,35 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_18 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , lux_listing_mapping_src_26003.listing_id AS listing - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 + lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , lux_listing_mapping_src_26000.listing_id AS listing + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 LEFT OUTER JOIN - ***************************.dim_lux_listings lux_listings_src_26004 + ***************************.dim_lux_listings lux_listings_src_26000 ON - lux_listing_mapping_src_26003.lux_listing_id = lux_listings_src_26004.lux_listing_id -) subq_18 + lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id +) subq_23 ON ( - subq_13.listing = subq_18.listing + subq_18.listing = subq_23.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.lux_listing__window_start__day + subq_18.metric_time__day >= subq_23.lux_listing__window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.lux_listing__window_end__day + subq_18.metric_time__day < subq_23.lux_listing__window_end__day ) OR ( - subq_18.lux_listing__window_end__day IS NULL + subq_23.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.lux_listing__is_confirmed_lux + subq_18.metric_time__day + , subq_23.lux_listing__is_confirmed_lux diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql index ff72ab3310..56b1b5e974 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql @@ -1,93 +1,93 @@ -- Compute Metrics via Expressions SELECT - subq_10.account_id__customer_id__customer_name - , subq_10.txn_count + subq_14.account_id__customer_id__customer_name + , subq_14.txn_count FROM ( -- Aggregate Measures SELECT - subq_9.account_id__customer_id__customer_name - , SUM(subq_9.txn_count) AS txn_count + subq_13.account_id__customer_id__customer_name + , SUM(subq_13.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_8.account_id__customer_id__customer_name - , subq_8.txn_count + subq_12.account_id__customer_id__customer_name + , subq_12.txn_count FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_2.account_id AS account_id - , subq_7.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_2.txn_count AS txn_count + subq_6.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_6.account_id AS account_id + , subq_11.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_6.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_1.ds_partitioned__day - , subq_1.account_id - , subq_1.txn_count + subq_5.ds_partitioned__day + , subq_5.account_id + , subq_5.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.account_id__ds_partitioned__day - , subq_0.account_id__ds_partitioned__week - , subq_0.account_id__ds_partitioned__month - , subq_0.account_id__ds_partitioned__quarter - , subq_0.account_id__ds_partitioned__year - , subq_0.account_id__ds_partitioned__extract_year - , subq_0.account_id__ds_partitioned__extract_quarter - , subq_0.account_id__ds_partitioned__extract_month - , subq_0.account_id__ds_partitioned__extract_day - , subq_0.account_id__ds_partitioned__extract_dow - , subq_0.account_id__ds_partitioned__extract_doy - , subq_0.account_id__ds__day - , subq_0.account_id__ds__week - , subq_0.account_id__ds__month - , subq_0.account_id__ds__quarter - , subq_0.account_id__ds__year - , subq_0.account_id__ds__extract_year - , subq_0.account_id__ds__extract_quarter - , subq_0.account_id__ds__extract_month - , subq_0.account_id__ds__extract_day - , subq_0.account_id__ds__extract_dow - , subq_0.account_id__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.account_id - , subq_0.account_month - , subq_0.account_id__account_month - , subq_0.txn_count + subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.account_id__ds_partitioned__day + , subq_4.account_id__ds_partitioned__week + , subq_4.account_id__ds_partitioned__month + , subq_4.account_id__ds_partitioned__quarter + , subq_4.account_id__ds_partitioned__year + , subq_4.account_id__ds_partitioned__extract_year + , subq_4.account_id__ds_partitioned__extract_quarter + , subq_4.account_id__ds_partitioned__extract_month + , subq_4.account_id__ds_partitioned__extract_day + , subq_4.account_id__ds_partitioned__extract_dow + , subq_4.account_id__ds_partitioned__extract_doy + , subq_4.account_id__ds__day + , subq_4.account_id__ds__week + , subq_4.account_id__ds__month + , subq_4.account_id__ds__quarter + , subq_4.account_id__ds__year + , subq_4.account_id__ds__extract_year + , subq_4.account_id__ds__extract_quarter + , subq_4.account_id__ds__extract_month + , subq_4.account_id__ds__extract_day + , subq_4.account_id__ds__extract_dow + , subq_4.account_id__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.account_id + , subq_4.account_month + , subq_4.account_id__account_month + , subq_4.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -140,118 +140,118 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_4 + ) subq_5 + ) subq_6 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_6.ds_partitioned__day - , subq_6.account_id - , subq_6.customer_id__customer_name + subq_10.ds_partitioned__day + , subq_10.account_id + , subq_10.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_3.ds_partitioned__day AS ds_partitioned__day - , subq_3.ds_partitioned__week AS ds_partitioned__week - , subq_3.ds_partitioned__month AS ds_partitioned__month - , subq_3.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_3.ds_partitioned__year AS ds_partitioned__year - , subq_3.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_3.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_3.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_3.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_3.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_3.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_3.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_3.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_3.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_3.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_3.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_3.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_3.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_5.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_5.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_5.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_5.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_5.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_5.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_3.account_id AS account_id - , subq_3.customer_id AS customer_id - , subq_3.account_id__customer_id AS account_id__customer_id - , subq_3.bridge_account__account_id AS bridge_account__account_id - , subq_3.bridge_account__customer_id AS bridge_account__customer_id - , subq_3.extra_dim AS extra_dim - , subq_3.account_id__extra_dim AS account_id__extra_dim - , subq_3.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_5.customer_name AS customer_id__customer_name - , subq_5.customer_atomic_weight AS customer_id__customer_atomic_weight + subq_7.ds_partitioned__day AS ds_partitioned__day + , subq_7.ds_partitioned__week AS ds_partitioned__week + , subq_7.ds_partitioned__month AS ds_partitioned__month + , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_7.ds_partitioned__year AS ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_9.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_9.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_9.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_9.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_9.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_9.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_7.account_id AS account_id + , subq_7.customer_id AS customer_id + , subq_7.account_id__customer_id AS account_id__customer_id + , subq_7.bridge_account__account_id AS bridge_account__account_id + , subq_7.bridge_account__customer_id AS bridge_account__customer_id + , subq_7.extra_dim AS extra_dim + , subq_7.account_id__extra_dim AS account_id__extra_dim + , subq_7.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_9.customer_name AS customer_id__customer_name + , subq_9.customer_atomic_weight AS customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT - bridge_table_src_22001.extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bridge_table_src_22001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bridge_table_src_22001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bridge_table_src_22001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS account_id__extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bridge_table_src_22001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bridge_table_src_22001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bridge_table_src_22001.ds_partitioned) END AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS bridge_account__extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bridge_table_src_22001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bridge_table_src_22001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bridge_table_src_22001.ds_partitioned) END AS bridge_account__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy - , bridge_table_src_22001.account_id - , bridge_table_src_22001.customer_id - , bridge_table_src_22001.customer_id AS account_id__customer_id - , bridge_table_src_22001.account_id AS bridge_account__account_id - , bridge_table_src_22001.customer_id AS bridge_account__customer_id - FROM ***************************.bridge_table bridge_table_src_22001 - ) subq_3 + bridge_table_src_22000.extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bridge_table_src_22000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bridge_table_src_22000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bridge_table_src_22000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS account_id__extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bridge_table_src_22000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bridge_table_src_22000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bridge_table_src_22000.ds_partitioned) END AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS bridge_account__extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bridge_table_src_22000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bridge_table_src_22000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bridge_table_src_22000.ds_partitioned) END AS bridge_account__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy + , bridge_table_src_22000.account_id + , bridge_table_src_22000.customer_id + , bridge_table_src_22000.customer_id AS account_id__customer_id + , bridge_table_src_22000.account_id AS bridge_account__account_id + , bridge_table_src_22000.customer_id AS bridge_account__customer_id + FROM ***************************.bridge_table bridge_table_src_22000 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -283,82 +283,82 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.customer_id__ds_partitioned__day - , subq_4.customer_id__ds_partitioned__week - , subq_4.customer_id__ds_partitioned__month - , subq_4.customer_id__ds_partitioned__quarter - , subq_4.customer_id__ds_partitioned__year - , subq_4.customer_id__ds_partitioned__extract_year - , subq_4.customer_id__ds_partitioned__extract_quarter - , subq_4.customer_id__ds_partitioned__extract_month - , subq_4.customer_id__ds_partitioned__extract_day - , subq_4.customer_id__ds_partitioned__extract_dow - , subq_4.customer_id__ds_partitioned__extract_doy - , subq_4.customer_id - , subq_4.customer_name - , subq_4.customer_atomic_weight - , subq_4.customer_id__customer_name - , subq_4.customer_id__customer_atomic_weight + subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.customer_id__ds_partitioned__day + , subq_8.customer_id__ds_partitioned__week + , subq_8.customer_id__ds_partitioned__month + , subq_8.customer_id__ds_partitioned__quarter + , subq_8.customer_id__ds_partitioned__year + , subq_8.customer_id__ds_partitioned__extract_year + , subq_8.customer_id__ds_partitioned__extract_quarter + , subq_8.customer_id__ds_partitioned__extract_month + , subq_8.customer_id__ds_partitioned__extract_day + , subq_8.customer_id__ds_partitioned__extract_dow + , subq_8.customer_id__ds_partitioned__extract_doy + , subq_8.customer_id + , subq_8.customer_name + , subq_8.customer_atomic_weight + , subq_8.customer_id__customer_name + , subq_8.customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT - customer_table_src_22003.customer_name - , customer_table_src_22003.customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_22003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_22003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_22003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_22003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM customer_table_src_22003.ds_partitioned) = 0 THEN EXTRACT(dow FROM customer_table_src_22003.ds_partitioned) + 7 ELSE EXTRACT(dow FROM customer_table_src_22003.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_doy - , customer_table_src_22003.customer_name AS customer_id__customer_name - , customer_table_src_22003.customer_atomic_weight AS customer_id__customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM customer_table_src_22003.ds_partitioned) = 0 THEN EXTRACT(dow FROM customer_table_src_22003.ds_partitioned) + 7 ELSE EXTRACT(dow FROM customer_table_src_22003.ds_partitioned) END AS customer_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_doy - , customer_table_src_22003.customer_id - FROM ***************************.customer_table customer_table_src_22003 - ) subq_4 - ) subq_5 + customer_table_src_22000.customer_name + , customer_table_src_22000.customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM customer_table_src_22000.ds_partitioned) = 0 THEN EXTRACT(dow FROM customer_table_src_22000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM customer_table_src_22000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , customer_table_src_22000.customer_name AS customer_id__customer_name + , customer_table_src_22000.customer_atomic_weight AS customer_id__customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM customer_table_src_22000.ds_partitioned) = 0 THEN EXTRACT(dow FROM customer_table_src_22000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM customer_table_src_22000.ds_partitioned) END AS customer_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy + , customer_table_src_22000.customer_id + FROM ***************************.customer_table customer_table_src_22000 + ) subq_8 + ) subq_9 ON ( - subq_3.customer_id = subq_5.customer_id + subq_7.customer_id = subq_9.customer_id ) AND ( - subq_3.ds_partitioned__day = subq_5.ds_partitioned__day + subq_7.ds_partitioned__day = subq_9.ds_partitioned__day ) - ) subq_6 - ) subq_7 + ) subq_10 + ) subq_11 ON ( - subq_2.account_id = subq_7.account_id + subq_6.account_id = subq_11.account_id ) AND ( - subq_2.ds_partitioned__day = subq_7.ds_partitioned__day + subq_6.ds_partitioned__day = subq_11.ds_partitioned__day ) - ) subq_8 - ) subq_9 + ) subq_12 + ) subq_13 GROUP BY - subq_9.account_id__customer_id__customer_name -) subq_10 + subq_13.account_id__customer_id__customer_name +) subq_14 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql index 7802d2f867..13473156ca 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql @@ -3,31 +3,31 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_18.customer_id__customer_name AS account_id__customer_id__customer_name + subq_22.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__day - , bridge_table_src_22001.account_id AS account_id - , customer_table_src_22003.customer_name AS customer_id__customer_name - FROM ***************************.bridge_table bridge_table_src_22001 + DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__day + , bridge_table_src_22000.account_id AS account_id + , customer_table_src_22000.customer_name AS customer_id__customer_name + FROM ***************************.bridge_table bridge_table_src_22000 LEFT OUTER JOIN - ***************************.customer_table customer_table_src_22003 + ***************************.customer_table customer_table_src_22000 ON ( - bridge_table_src_22001.customer_id = customer_table_src_22003.customer_id + bridge_table_src_22000.customer_id = customer_table_src_22000.customer_id ) AND ( - DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) + DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_18 +) subq_22 ON ( - account_month_txns_src_22000.account_id = subq_18.account_id + account_month_txns_src_22000.account_id = subq_22.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day ) GROUP BY - subq_18.customer_id__customer_name + subq_22.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql index 54c6113672..6ab0dac460 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql @@ -1,536 +1,536 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_5.bookings) AS bookings - , MAX(subq_11.listings) AS listings + MAX(subq_18.bookings) AS bookings + , MAX(subq_24.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_4.bookings + subq_17.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_3.bookings) AS bookings + SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_2.bookings + subq_15.bookings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.ds_partitioned__day - , subq_1.ds_partitioned__week - , subq_1.ds_partitioned__month - , subq_1.ds_partitioned__quarter - , subq_1.ds_partitioned__year - , subq_1.ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy - , subq_1.paid_at__day - , subq_1.paid_at__week - , subq_1.paid_at__month - , subq_1.paid_at__quarter - , subq_1.paid_at__year - , subq_1.paid_at__extract_year - , subq_1.paid_at__extract_quarter - , subq_1.paid_at__extract_month - , subq_1.paid_at__extract_day - , subq_1.paid_at__extract_dow - , subq_1.paid_at__extract_doy - , subq_1.booking__ds__day - , subq_1.booking__ds__week - , subq_1.booking__ds__month - , subq_1.booking__ds__quarter - , subq_1.booking__ds__year - , subq_1.booking__ds__extract_year - , subq_1.booking__ds__extract_quarter - , subq_1.booking__ds__extract_month - , subq_1.booking__ds__extract_day - , subq_1.booking__ds__extract_dow - , subq_1.booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day - , subq_1.booking__paid_at__week - , subq_1.booking__paid_at__month - , subq_1.booking__paid_at__quarter - , subq_1.booking__paid_at__year - , subq_1.booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.listing - , subq_1.guest - , subq_1.host - , subq_1.booking__listing - , subq_1.booking__guest - , subq_1.booking__host - , subq_1.is_instant - , subq_1.booking__is_instant - , subq_1.bookings - , subq_1.instant_bookings - , subq_1.booking_value - , subq_1.max_booking_value - , subq_1.min_booking_value - , subq_1.bookers - , subq_1.average_booking_value - , subq_1.referred_bookings - , subq_1.median_booking_value - , subq_1.booking_value_p99 - , subq_1.discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 + subq_14.ds__day + , subq_14.ds__week + , subq_14.ds__month + , subq_14.ds__quarter + , subq_14.ds__year + , subq_14.ds__extract_year + , subq_14.ds__extract_quarter + , subq_14.ds__extract_month + , subq_14.ds__extract_day + , subq_14.ds__extract_dow + , subq_14.ds__extract_doy + , subq_14.ds_partitioned__day + , subq_14.ds_partitioned__week + , subq_14.ds_partitioned__month + , subq_14.ds_partitioned__quarter + , subq_14.ds_partitioned__year + , subq_14.ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy + , subq_14.paid_at__day + , subq_14.paid_at__week + , subq_14.paid_at__month + , subq_14.paid_at__quarter + , subq_14.paid_at__year + , subq_14.paid_at__extract_year + , subq_14.paid_at__extract_quarter + , subq_14.paid_at__extract_month + , subq_14.paid_at__extract_day + , subq_14.paid_at__extract_dow + , subq_14.paid_at__extract_doy + , subq_14.booking__ds__day + , subq_14.booking__ds__week + , subq_14.booking__ds__month + , subq_14.booking__ds__quarter + , subq_14.booking__ds__year + , subq_14.booking__ds__extract_year + , subq_14.booking__ds__extract_quarter + , subq_14.booking__ds__extract_month + , subq_14.booking__ds__extract_day + , subq_14.booking__ds__extract_dow + , subq_14.booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day + , subq_14.booking__paid_at__week + , subq_14.booking__paid_at__month + , subq_14.booking__paid_at__quarter + , subq_14.booking__paid_at__year + , subq_14.booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy + , subq_14.metric_time__day + , subq_14.metric_time__week + , subq_14.metric_time__month + , subq_14.metric_time__quarter + , subq_14.metric_time__year + , subq_14.metric_time__extract_year + , subq_14.metric_time__extract_quarter + , subq_14.metric_time__extract_month + , subq_14.metric_time__extract_day + , subq_14.metric_time__extract_dow + , subq_14.metric_time__extract_doy + , subq_14.listing + , subq_14.guest + , subq_14.host + , subq_14.booking__listing + , subq_14.booking__guest + , subq_14.booking__host + , subq_14.is_instant + , subq_14.booking__is_instant + , subq_14.bookings + , subq_14.instant_bookings + , subq_14.booking_value + , subq_14.max_booking_value + , subq_14.min_booking_value + , subq_14.bookers + , subq_14.average_booking_value + , subq_14.referred_bookings + , subq_14.median_booking_value + , subq_14.booking_value_p99 + , subq_14.discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_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 + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.max_booking_value + , subq_13.min_booking_value + , subq_13.bookers + , subq_13.average_booking_value + , subq_13.referred_bookings + , subq_13.median_booking_value + , subq_13.booking_value_p99 + , subq_13.discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_2 - ) subq_3 - ) subq_4 -) subq_5 + , 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_13 + ) subq_14 + WHERE subq_14.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_15 + ) subq_16 + ) subq_17 +) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.listings + subq_23.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_9.listings) AS listings + SUM(subq_22.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_8.listings + subq_21.listings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] 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.created_at__day - , subq_7.created_at__week - , subq_7.created_at__month - , subq_7.created_at__quarter - , subq_7.created_at__year - , subq_7.created_at__extract_year - , subq_7.created_at__extract_quarter - , subq_7.created_at__extract_month - , subq_7.created_at__extract_day - , subq_7.created_at__extract_dow - , subq_7.created_at__extract_doy - , subq_7.listing__ds__day - , subq_7.listing__ds__week - , subq_7.listing__ds__month - , subq_7.listing__ds__quarter - , subq_7.listing__ds__year - , subq_7.listing__ds__extract_year - , subq_7.listing__ds__extract_quarter - , subq_7.listing__ds__extract_month - , subq_7.listing__ds__extract_day - , subq_7.listing__ds__extract_dow - , subq_7.listing__ds__extract_doy - , subq_7.listing__created_at__day - , subq_7.listing__created_at__week - , subq_7.listing__created_at__month - , subq_7.listing__created_at__quarter - , subq_7.listing__created_at__year - , subq_7.listing__created_at__extract_year - , subq_7.listing__created_at__extract_quarter - , subq_7.listing__created_at__extract_month - , subq_7.listing__created_at__extract_day - , subq_7.listing__created_at__extract_dow - , subq_7.listing__created_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.user - , subq_7.listing__user - , subq_7.country_latest - , subq_7.is_lux_latest - , subq_7.capacity_latest - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.listings - , subq_7.largest_listing - , subq_7.smallest_listing + 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.created_at__day + , subq_20.created_at__week + , subq_20.created_at__month + , subq_20.created_at__quarter + , subq_20.created_at__year + , subq_20.created_at__extract_year + , subq_20.created_at__extract_quarter + , subq_20.created_at__extract_month + , subq_20.created_at__extract_day + , subq_20.created_at__extract_dow + , subq_20.created_at__extract_doy + , subq_20.listing__ds__day + , subq_20.listing__ds__week + , subq_20.listing__ds__month + , subq_20.listing__ds__quarter + , subq_20.listing__ds__year + , subq_20.listing__ds__extract_year + , subq_20.listing__ds__extract_quarter + , subq_20.listing__ds__extract_month + , subq_20.listing__ds__extract_day + , subq_20.listing__ds__extract_dow + , subq_20.listing__ds__extract_doy + , subq_20.listing__created_at__day + , subq_20.listing__created_at__week + , subq_20.listing__created_at__month + , subq_20.listing__created_at__quarter + , subq_20.listing__created_at__year + , subq_20.listing__created_at__extract_year + , subq_20.listing__created_at__extract_quarter + , subq_20.listing__created_at__extract_month + , subq_20.listing__created_at__extract_day + , subq_20.listing__created_at__extract_dow + , subq_20.listing__created_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.user + , subq_20.listing__user + , subq_20.country_latest + , subq_20.is_lux_latest + , subq_20.capacity_latest + , subq_20.listing__country_latest + , subq_20.listing__is_lux_latest + , subq_20.listing__capacity_latest + , subq_20.listings + , subq_20.largest_listing + , subq_20.smallest_listing FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_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.created_at__day + , subq_19.created_at__week + , subq_19.created_at__month + , subq_19.created_at__quarter + , subq_19.created_at__year + , subq_19.created_at__extract_year + , subq_19.created_at__extract_quarter + , subq_19.created_at__extract_month + , subq_19.created_at__extract_day + , subq_19.created_at__extract_dow + , subq_19.created_at__extract_doy + , subq_19.listing__ds__day + , subq_19.listing__ds__week + , subq_19.listing__ds__month + , subq_19.listing__ds__quarter + , subq_19.listing__ds__year + , subq_19.listing__ds__extract_year + , subq_19.listing__ds__extract_quarter + , subq_19.listing__ds__extract_month + , subq_19.listing__ds__extract_day + , subq_19.listing__ds__extract_dow + , subq_19.listing__ds__extract_doy + , subq_19.listing__created_at__day + , subq_19.listing__created_at__week + , subq_19.listing__created_at__month + , subq_19.listing__created_at__quarter + , subq_19.listing__created_at__year + , subq_19.listing__created_at__extract_year + , subq_19.listing__created_at__extract_quarter + , subq_19.listing__created_at__extract_month + , subq_19.listing__created_at__extract_day + , subq_19.listing__created_at__extract_dow + , subq_19.listing__created_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.user + , subq_19.listing__user + , subq_19.country_latest + , subq_19.is_lux_latest + , subq_19.capacity_latest + , subq_19.listing__country_latest + , subq_19.listing__is_lux_latest + , subq_19.listing__capacity_latest + , subq_19.listings + , subq_19.largest_listing + , subq_19.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28005.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28005.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28005.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_6 - ) subq_7 - WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_8 - ) subq_9 - ) subq_10 -) subq_11 + , 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_19 + ) subq_20 + WHERE subq_20.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_21 + ) subq_22 + ) subq_23 +) subq_24 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 2691ca3c38..71a7d98121 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_17.bookings) AS bookings - , MAX(subq_23.listings) AS listings + MAX(subq_30.bookings) AS bookings + , MAX(subq_36.listings) AS listings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -11,9 +11,9 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_17 +) subq_30 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -23,6 +23,6 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_23 +) subq_36 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql index f13ef5a49e..5f046defd4 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql @@ -1,241 +1,241 @@ -- Compute Metrics via Expressions SELECT - subq_7.user__home_state - , subq_7.identity_verifications + subq_16.user__home_state + , subq_16.identity_verifications FROM ( -- Aggregate Measures SELECT - subq_6.user__home_state - , SUM(subq_6.identity_verifications) AS identity_verifications + subq_15.user__home_state + , SUM(subq_15.identity_verifications) AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'user__home_state'] SELECT - subq_5.user__home_state - , subq_5.identity_verifications + subq_14.user__home_state + , subq_14.identity_verifications FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__day AS user__ds_partitioned__day - , subq_2.user AS user - , subq_4.home_state AS user__home_state - , subq_2.identity_verifications AS identity_verifications + subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__day AS user__ds_partitioned__day + , subq_11.user AS user + , subq_13.home_state AS user__home_state + , subq_11.identity_verifications AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT - subq_1.ds_partitioned__day - , subq_1.user - , subq_1.identity_verifications + subq_10.ds_partitioned__day + , subq_10.user + , subq_10.identity_verifications 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.verification__ds__day - , subq_0.verification__ds__week - , subq_0.verification__ds__month - , subq_0.verification__ds__quarter - , subq_0.verification__ds__year - , subq_0.verification__ds__extract_year - , subq_0.verification__ds__extract_quarter - , subq_0.verification__ds__extract_month - , subq_0.verification__ds__extract_day - , subq_0.verification__ds__extract_dow - , subq_0.verification__ds__extract_doy - , subq_0.verification__ds_partitioned__day - , subq_0.verification__ds_partitioned__week - , subq_0.verification__ds_partitioned__month - , subq_0.verification__ds_partitioned__quarter - , subq_0.verification__ds_partitioned__year - , subq_0.verification__ds_partitioned__extract_year - , subq_0.verification__ds_partitioned__extract_quarter - , subq_0.verification__ds_partitioned__extract_month - , subq_0.verification__ds_partitioned__extract_day - , subq_0.verification__ds_partitioned__extract_dow - , subq_0.verification__ds_partitioned__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.verification - , subq_0.user - , subq_0.verification__user - , subq_0.verification_type - , subq_0.verification__verification_type - , subq_0.identity_verifications + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.verification__ds__day + , subq_9.verification__ds__week + , subq_9.verification__ds__month + , subq_9.verification__ds__quarter + , subq_9.verification__ds__year + , subq_9.verification__ds__extract_year + , subq_9.verification__ds__extract_quarter + , subq_9.verification__ds__extract_month + , subq_9.verification__ds__extract_day + , subq_9.verification__ds__extract_dow + , subq_9.verification__ds__extract_doy + , subq_9.verification__ds_partitioned__day + , subq_9.verification__ds_partitioned__week + , subq_9.verification__ds_partitioned__month + , subq_9.verification__ds_partitioned__quarter + , subq_9.verification__ds_partitioned__year + , subq_9.verification__ds_partitioned__extract_year + , subq_9.verification__ds_partitioned__extract_quarter + , subq_9.verification__ds_partitioned__extract_month + , subq_9.verification__ds_partitioned__extract_day + , subq_9.verification__ds_partitioned__extract_dow + , subq_9.verification__ds_partitioned__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.verification + , subq_9.user + , subq_9.verification__user + , subq_9.verification_type + , subq_9.verification__verification_type + , subq_9.identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_28004.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_28004.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28004.ds) END AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_28004.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_28004.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28004.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_28004.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_28004.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28004.ds) END AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM id_verifications_src_28004.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_28004.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28004.ds_partitioned) END AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user - FROM ***************************.fct_id_verifications id_verifications_src_28004 - ) subq_0 - ) subq_1 - ) subq_2 + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_28000.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_28000.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_28000.ds) = 0 THEN EXTRACT(dow FROM id_verifications_src_28000.ds) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28000.ds) END AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM id_verifications_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM id_verifications_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM id_verifications_src_28000.ds_partitioned) END AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user + FROM ***************************.fct_id_verifications id_verifications_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state', 'ds_partitioned__day', 'user'] SELECT - subq_3.ds_partitioned__day - , subq_3.user - , subq_3.home_state + subq_12.ds_partitioned__day + , subq_12.user + , subq_12.home_state FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - DATE_TRUNC('day', users_ds_source_src_28008.ds) AS ds__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds) AS ds__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds) AS ds__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds) AS ds__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds) AS ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28008.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28008.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28008.ds) END AS ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds) AS ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.created_at) AS created_at__day - , DATE_TRUNC('week', users_ds_source_src_28008.created_at) AS created_at__week - , DATE_TRUNC('month', users_ds_source_src_28008.created_at) AS created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.created_at) AS created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.created_at) AS created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28008.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28008.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28008.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.created_at) AS created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28008.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28008.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28008.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state - , DATE_TRUNC('day', users_ds_source_src_28008.ds) AS user__ds__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds) AS user__ds__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds) AS user__ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS user__ds__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28008.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28008.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28008.ds) END AS user__ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds) AS user__ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.created_at) AS user__created_at__day - , DATE_TRUNC('week', users_ds_source_src_28008.created_at) AS user__created_at__week - , DATE_TRUNC('month', users_ds_source_src_28008.created_at) AS user__created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.created_at) AS user__created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.created_at) AS user__created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28008.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28008.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28008.created_at) END AS user__created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28008.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28008.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28008.ds_partitioned) END AS user__ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state AS user__home_state - , users_ds_source_src_28008.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28008 - ) subq_3 - ) subq_4 + DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds) END AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.created_at) END AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) END AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_12 + ) subq_13 ON ( - subq_2.user = subq_4.user + subq_11.user = subq_13.user ) AND ( - subq_2.ds_partitioned__day = subq_4.ds_partitioned__day + subq_11.ds_partitioned__day = subq_13.ds_partitioned__day ) - ) subq_5 - ) subq_6 + ) subq_14 + ) subq_15 GROUP BY - subq_6.user__home_state -) subq_7 + subq_15.user__home_state +) subq_16 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql index 9f15f9bb3d..54ea641813 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql @@ -3,8 +3,8 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - users_ds_source_src_28008.home_state AS user__home_state - , SUM(subq_10.identity_verifications) AS identity_verifications + users_ds_source_src_28000.home_state AS user__home_state + , SUM(subq_19.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' -- Metric Time Dimension 'ds' @@ -13,15 +13,15 @@ FROM ( DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications - FROM ***************************.fct_id_verifications id_verifications_src_28004 -) subq_10 + FROM ***************************.fct_id_verifications id_verifications_src_28000 +) subq_19 LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_28008 + ***************************.dim_users users_ds_source_src_28000 ON ( - subq_10.user = users_ds_source_src_28008.user_id + subq_19.user = users_ds_source_src_28000.user_id ) AND ( - subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) + subq_19.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) ) GROUP BY - users_ds_source_src_28008.home_state + users_ds_source_src_28000.home_state diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0.sql index 8d2fbedfb7..c1da034888 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0.sql @@ -1,439 +1,439 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_value) AS booking_value + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 -) subq_4 + subq_11.metric_time__day + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_value) AS booking_value + subq_16.metric_time__day + , SUM(subq_16.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_value + subq_15.metric_time__day + , subq_15.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_16.metric_time__day + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0_optimized.sql index ccc0d8cd89..7831d40fe6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql index bee4c90b0a..0a82b5e771 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql @@ -68,62 +68,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0_optimized.sql index 22b719da85..1653ada5bd 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_3 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql index 3bab159275..0e227f046d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -1,383 +1,383 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_19.booking__is_instant + , subq_19.bookings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_18.booking__is_instant + , SUM(subq_18.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_17.booking__is_instant + , subq_17.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_16.booking__is_instant + , subq_16.listing__country_latest + , subq_16.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.booking__is_instant + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.listing + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__country_latest = 'us' - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_18.booking__is_instant +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index fdbb61ce0e..433c9799b5 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.country AS listing__country_latest - , subq_13.bookings AS bookings + subq_22.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.country AS listing__country_latest + , subq_22.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -20,13 +20,13 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28005.listing_id -) subq_18 + subq_22.listing = listings_latest_src_28000.listing_id +) subq_27 WHERE listing__country_latest = 'us' GROUP BY booking__is_instant diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql index 9ce4b38f01..e388c0616b 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql @@ -1,139 +1,139 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS family_bookings + subq_11.metric_time__day + , subq_11.bookings AS family_bookings FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_10.metric_time__day + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.listing__capacity - , subq_6.bookings + subq_8.metric_time__day + , subq_8.listing__capacity + , subq_8.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.listing__capacity - , subq_5.bookings + subq_7.metric_time__day + , subq_7.listing__capacity + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_4.window_start__day AS listing__window_start__day - , subq_4.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_4.capacity AS listing__capacity - , subq_2.bookings AS bookings + subq_4.metric_time__day AS metric_time__day + , subq_6.window_start__day AS listing__window_start__day + , subq_6.window_end__day AS listing__window_end__day + , subq_4.listing AS listing + , subq_6.capacity AS listing__capacity + , subq_4.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_3.metric_time__day + , subq_3.listing + , subq_3.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + 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.user + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.booking__user + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.bookers + , subq_2.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -220,94 +220,94 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_2 + ) subq_3 + ) subq_4 LEFT OUTER JOIN ( -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_3.window_start__day - , subq_3.window_end__day - , subq_3.listing - , subq_3.capacity + subq_5.window_start__day + , subq_5.window_end__day + , subq_5.listing + , subq_5.capacity FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , EXTRACT(dayofweekiso FROM listings_src_26002.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , EXTRACT(dayofweekiso FROM listings_src_26002.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , EXTRACT(dayofweekiso FROM listings_src_26002.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , EXTRACT(dayofweekiso FROM listings_src_26002.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 - ) subq_4 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , EXTRACT(dayofweekiso FROM listings_src_26000.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , EXTRACT(dayofweekiso FROM listings_src_26000.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , EXTRACT(dayofweekiso FROM listings_src_26000.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , EXTRACT(dayofweekiso FROM listings_src_26000.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_4.listing + subq_4.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_4.window_start__day + subq_4.metric_time__day >= subq_6.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_4.window_end__day + subq_4.metric_time__day < subq_6.window_end__day ) OR ( - subq_4.window_end__day IS NULL + subq_6.window_end__day IS NULL ) ) ) - ) subq_5 - ) subq_6 + ) subq_7 + ) subq_8 WHERE listing__capacity > 2 - ) subq_7 - ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_8.metric_time__day -) subq_9 + subq_10.metric_time__day +) subq_11 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql index fc848091b1..0f3bd95cd6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_12.metric_time__day AS metric_time__day - , listings_src_26002.capacity AS listing__capacity - , subq_12.bookings AS bookings + subq_14.metric_time__day AS metric_time__day + , listings_src_26000.capacity AS listing__capacity + , subq_14.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -21,24 +21,24 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_12 + ) subq_14 LEFT OUTER JOIN - ***************************.dim_listings listings_src_26002 + ***************************.dim_listings listings_src_26000 ON ( - subq_12.listing = listings_src_26002.listing_id + subq_14.listing = listings_src_26000.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_26002.active_from + subq_14.metric_time__day >= listings_src_26000.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_26002.active_to + subq_14.metric_time__day < listings_src_26000.active_to ) OR ( - listings_src_26002.active_to IS NULL + listings_src_26000.active_to IS NULL ) ) ) -) subq_16 +) subq_18 WHERE listing__capacity > 2 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0.sql index 53f2360a79..607cab5bac 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0.sql @@ -1,220 +1,220 @@ -- Order By [] Limit 1 SELECT - subq_4.ds__day - , subq_4.bookings + subq_13.ds__day + , subq_13.bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.bookings + subq_12.ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.bookings + subq_10.ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__day - ) subq_3 -) subq_4 + subq_11.ds__day + ) subq_12 +) subq_13 LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0_optimized.sql index a71f7ae0e8..0780ad9c07 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0_optimized.sql @@ -11,8 +11,8 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_7 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_16 GROUP BY ds__day LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0.sql index ffecf2d0db..5667b89e60 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0.sql @@ -1,150 +1,150 @@ -- Compute Metrics via Expressions SELECT - subq_3.listing__country_latest - , subq_3.listings + subq_12.listing__country_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_2.listing__country_latest - , SUM(subq_2.listings) AS listings + subq_11.listing__country_latest + , SUM(subq_11.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'listing__country_latest'] SELECT - subq_1.listing__country_latest - , subq_1.listings + subq_10.listing__country_latest + , subq_10.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.created_at__day - , subq_0.created_at__week - , subq_0.created_at__month - , subq_0.created_at__quarter - , subq_0.created_at__year - , subq_0.created_at__extract_year - , subq_0.created_at__extract_quarter - , subq_0.created_at__extract_month - , subq_0.created_at__extract_day - , subq_0.created_at__extract_dow - , subq_0.created_at__extract_doy - , subq_0.listing__ds__day - , subq_0.listing__ds__week - , subq_0.listing__ds__month - , subq_0.listing__ds__quarter - , subq_0.listing__ds__year - , subq_0.listing__ds__extract_year - , subq_0.listing__ds__extract_quarter - , subq_0.listing__ds__extract_month - , subq_0.listing__ds__extract_day - , subq_0.listing__ds__extract_dow - , subq_0.listing__ds__extract_doy - , subq_0.listing__created_at__day - , subq_0.listing__created_at__week - , subq_0.listing__created_at__month - , subq_0.listing__created_at__quarter - , subq_0.listing__created_at__year - , subq_0.listing__created_at__extract_year - , subq_0.listing__created_at__extract_quarter - , subq_0.listing__created_at__extract_month - , subq_0.listing__created_at__extract_day - , subq_0.listing__created_at__extract_dow - , subq_0.listing__created_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.user - , subq_0.listing__user - , subq_0.country_latest - , subq_0.is_lux_latest - , subq_0.capacity_latest - , subq_0.listing__country_latest - , subq_0.listing__is_lux_latest - , subq_0.listing__capacity_latest - , subq_0.listings - , subq_0.largest_listing - , subq_0.smallest_listing + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.listing__country_latest -) subq_3 + subq_11.listing__country_latest +) subq_12 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0_optimized.sql index 8486e86449..c0733d39a6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT country AS listing__country_latest , 1 AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_6 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_15 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql index 9f1663dda3..2bdb1447e7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql @@ -1,1003 +1,1003 @@ -- Compute Metrics via Expressions SELECT - subq_29.metric_time__day + subq_38.metric_time__day , average_booking_value * bookings / NULLIF(booking_value, 0) AS lux_booking_value_rate_expr FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_28.booking_value) AS booking_value + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_37.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_19.metric_time__day + , subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , AVG(subq_9.average_booking_value) AS average_booking_value + subq_18.metric_time__day + , AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_17.metric_time__day + , subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.metric_time__day + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.metric_time__day + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.average_booking_value AS average_booking_value + subq_11.metric_time__day AS metric_time__day + , subq_11.listing AS listing + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.average_booking_value + subq_10.metric_time__day + , subq_10.listing + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_18.metric_time__day + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day - , subq_22.bookings + subq_31.metric_time__day + , subq_31.bookings FROM ( -- Aggregate Measures SELECT - subq_21.metric_time__day - , SUM(subq_21.bookings) AS bookings + subq_30.metric_time__day + , SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.metric_time__day + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.metric_time__day + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.metric_time__day AS metric_time__day + , subq_23.listing AS listing + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.bookings + subq_22.metric_time__day + , subq_22.listing + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE listing__is_lux_latest - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 GROUP BY - subq_21.metric_time__day - ) subq_22 - ) subq_23 + subq_30.metric_time__day + ) subq_31 + ) subq_32 ON - subq_11.metric_time__day = subq_23.metric_time__day + subq_20.metric_time__day = subq_32.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.booking_value + subq_36.metric_time__day + , subq_36.booking_value FROM ( -- Aggregate Measures SELECT - subq_26.metric_time__day - , SUM(subq_26.booking_value) AS booking_value + subq_35.metric_time__day + , SUM(subq_35.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_25.metric_time__day - , subq_25.booking_value + subq_34.metric_time__day + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 GROUP BY - subq_26.metric_time__day - ) subq_27 - ) subq_28 + subq_35.metric_time__day + ) subq_36 + ) subq_37 ON - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day) = subq_37.metric_time__day GROUP BY - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) -) subq_29 + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day, subq_37.metric_time__day) +) subq_38 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql index 69ba3892a2..91ab825138 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) AS metric_time__day - , MAX(subq_41.average_booking_value) AS average_booking_value - , MAX(subq_53.bookings) AS bookings - , MAX(subq_58.booking_value) AS booking_value + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day, subq_67.metric_time__day) AS metric_time__day + , MAX(subq_50.average_booking_value) AS average_booking_value + , MAX(subq_62.bookings) AS bookings + , MAX(subq_67.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -21,19 +21,19 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - DATE_TRUNC('day', bookings_source_src_28001.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + DATE_TRUNC('day', bookings_source_src_28000.ds) AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_37 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_46 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_41 + ) subq_50 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -46,9 +46,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_44.metric_time__day AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_44.bookings AS bookings + subq_53.metric_time__day AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_53.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -57,19 +57,19 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_44 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_53 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_44.listing = listings_latest_src_28005.listing_id - ) subq_49 + subq_53.listing = listings_latest_src_28000.listing_id + ) subq_58 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_53 + ) subq_62 ON - subq_41.metric_time__day = subq_53.metric_time__day + subq_50.metric_time__day = subq_62.metric_time__day FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -79,12 +79,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_58 + ) subq_67 ON - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day) = subq_58.metric_time__day + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day) = subq_67.metric_time__day GROUP BY - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) -) subq_59 + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day, subq_67.metric_time__day) +) subq_68 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql index cd1568ae84..fcb94460bf 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,460 +1,460 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , CAST(subq_12.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_12.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio + subq_21.metric_time__day + , CAST(subq_21.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_21.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , MAX(subq_6.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_11.booking_value) AS booking_value + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day + , MAX(subq_15.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_20.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.booking_value AS booking_value_with_is_instant_constraint + subq_14.metric_time__day + , subq_14.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.booking_value) AS booking_value + subq_13.metric_time__day + , SUM(subq_13.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.booking_value + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_13.metric_time__day + ) subq_14 + ) subq_15 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_19.metric_time__day + , subq_19.booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.booking_value) AS booking_value + subq_18.metric_time__day + , SUM(subq_18.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.ds_partitioned__day + , subq_16.ds_partitioned__week + , subq_16.ds_partitioned__month + , subq_16.ds_partitioned__quarter + , subq_16.ds_partitioned__year + , subq_16.ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy + , subq_16.paid_at__day + , subq_16.paid_at__week + , subq_16.paid_at__month + , subq_16.paid_at__quarter + , subq_16.paid_at__year + , subq_16.paid_at__extract_year + , subq_16.paid_at__extract_quarter + , subq_16.paid_at__extract_month + , subq_16.paid_at__extract_day + , subq_16.paid_at__extract_dow + , subq_16.paid_at__extract_doy + , subq_16.booking__ds__day + , subq_16.booking__ds__week + , subq_16.booking__ds__month + , subq_16.booking__ds__quarter + , subq_16.booking__ds__year + , subq_16.booking__ds__extract_year + , subq_16.booking__ds__extract_quarter + , subq_16.booking__ds__extract_month + , subq_16.booking__ds__extract_day + , subq_16.booking__ds__extract_dow + , subq_16.booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day + , subq_16.booking__paid_at__week + , subq_16.booking__paid_at__month + , subq_16.booking__paid_at__quarter + , subq_16.booking__paid_at__year + , subq_16.booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.listing + , subq_16.guest + , subq_16.host + , subq_16.booking__listing + , subq_16.booking__guest + , subq_16.booking__host + , subq_16.is_instant + , subq_16.booking__is_instant + , subq_16.bookings + , subq_16.instant_bookings + , subq_16.booking_value + , subq_16.max_booking_value + , subq_16.min_booking_value + , subq_16.bookers + , subq_16.average_booking_value + , subq_16.referred_bookings + , subq_16.median_booking_value + , subq_16.booking_value_p99 + , subq_16.discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 + , subq_16.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_7 - ) subq_8 - ) subq_9 + , 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_16 + ) subq_17 + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_18.metric_time__day + ) subq_19 + ) subq_20 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_15.metric_time__day = subq_20.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) +) subq_21 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql index d384201243..e6c18549b2 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/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_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , MAX(subq_19.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_24.booking_value) AS booking_value + COALESCE(subq_28.metric_time__day, subq_33.metric_time__day) AS metric_time__day + , MAX(subq_28.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_33.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_28 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -39,12 +39,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_33 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_28.metric_time__day = subq_33.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_28.metric_time__day, subq_33.metric_time__day) +) subq_34 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 40af5c2e28..715c1d95a7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,234 +1,234 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day + subq_15.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.bookings AS delayed_bookings + subq_14.metric_time__day + , subq_14.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_13.metric_time__day + , SUM(subq_13.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE NOT booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY - subq_4.metric_time__day - ) subq_5 -) subq_6 + subq_13.metric_time__day + ) subq_14 +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index df414b0013..c494772d25 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -18,9 +18,9 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 2bef26e558..9109eac72f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -1,366 +1,366 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_10.bookings AS DOUBLE) / CAST(NULLIF(subq_10.listings, 0) AS DOUBLE) AS bookings_per_listing + CAST(subq_19.bookings AS DOUBLE) / CAST(NULLIF(subq_19.listings, 0) AS DOUBLE) AS bookings_per_listing FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_4.bookings) AS bookings - , MAX(subq_9.listings) AS listings + MAX(subq_13.bookings) AS bookings + , MAX(subq_18.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.bookings + subq_12.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_2.bookings) AS bookings + SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_1.bookings + subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 - ) subq_4 + , 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_9 + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.listings + subq_17.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_7.listings) AS listings + SUM(subq_16.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_6.listings + subq_15.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.created_at__day - , subq_5.created_at__week - , subq_5.created_at__month - , subq_5.created_at__quarter - , subq_5.created_at__year - , subq_5.created_at__extract_year - , subq_5.created_at__extract_quarter - , subq_5.created_at__extract_month - , subq_5.created_at__extract_day - , subq_5.created_at__extract_dow - , subq_5.created_at__extract_doy - , subq_5.listing__ds__day - , subq_5.listing__ds__week - , subq_5.listing__ds__month - , subq_5.listing__ds__quarter - , subq_5.listing__ds__year - , subq_5.listing__ds__extract_year - , subq_5.listing__ds__extract_quarter - , subq_5.listing__ds__extract_month - , subq_5.listing__ds__extract_day - , subq_5.listing__ds__extract_dow - , subq_5.listing__ds__extract_doy - , subq_5.listing__created_at__day - , subq_5.listing__created_at__week - , subq_5.listing__created_at__month - , subq_5.listing__created_at__quarter - , subq_5.listing__created_at__year - , subq_5.listing__created_at__extract_year - , subq_5.listing__created_at__extract_quarter - , subq_5.listing__created_at__extract_month - , subq_5.listing__created_at__extract_day - , subq_5.listing__created_at__extract_dow - , subq_5.listing__created_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.user - , subq_5.listing__user - , subq_5.country_latest - , subq_5.is_lux_latest - , subq_5.capacity_latest - , subq_5.listing__country_latest - , subq_5.listing__is_lux_latest - , subq_5.listing__capacity_latest - , subq_5.listings - , subq_5.largest_listing - , subq_5.smallest_listing + 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.created_at__day + , subq_14.created_at__week + , subq_14.created_at__month + , subq_14.created_at__quarter + , subq_14.created_at__year + , subq_14.created_at__extract_year + , subq_14.created_at__extract_quarter + , subq_14.created_at__extract_month + , subq_14.created_at__extract_day + , subq_14.created_at__extract_dow + , subq_14.created_at__extract_doy + , subq_14.listing__ds__day + , subq_14.listing__ds__week + , subq_14.listing__ds__month + , subq_14.listing__ds__quarter + , subq_14.listing__ds__year + , subq_14.listing__ds__extract_year + , subq_14.listing__ds__extract_quarter + , subq_14.listing__ds__extract_month + , subq_14.listing__ds__extract_day + , subq_14.listing__ds__extract_dow + , subq_14.listing__ds__extract_doy + , subq_14.listing__created_at__day + , subq_14.listing__created_at__week + , subq_14.listing__created_at__month + , subq_14.listing__created_at__quarter + , subq_14.listing__created_at__year + , subq_14.listing__created_at__extract_year + , subq_14.listing__created_at__extract_quarter + , subq_14.listing__created_at__extract_month + , subq_14.listing__created_at__extract_day + , subq_14.listing__created_at__extract_dow + , subq_14.listing__created_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.user + , subq_14.listing__user + , subq_14.country_latest + , subq_14.is_lux_latest + , subq_14.capacity_latest + , subq_14.listing__country_latest + , subq_14.listing__is_lux_latest + , subq_14.listing__capacity_latest + , subq_14.listings + , subq_14.largest_listing + , subq_14.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_5 - ) subq_6 - ) subq_7 - ) subq_8 - ) subq_9 -) subq_10 + , 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_14 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index 13f8ff2353..c293244ecc 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_15.bookings) AS DOUBLE) / CAST(NULLIF(MAX(subq_20.listings), 0) AS DOUBLE) AS bookings_per_listing + CAST(MAX(subq_24.bookings) AS DOUBLE) / CAST(NULLIF(MAX(subq_29.listings), 0) AS DOUBLE) AS bookings_per_listing FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -10,8 +10,8 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_24 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -20,5 +20,5 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_20 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_29 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_categorical__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_categorical__plan0.sql index 43b74e5a69..7c3e778ec5 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_categorical__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_categorical__plan0.sql @@ -10,62 +10,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 GROUP BY subq_0.listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_categorical__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_categorical__plan0_optimized.sql index c1da0c0382..a8d1afa6a8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_categorical__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_categorical__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 GROUP BY country ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time__plan0.sql index 025fd50a2a..3eac93eef4 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY subq_0.booking__paid_at__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time__plan0_optimized.sql index 280b915894..e6a861c58f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__day',] SELECT DATE_TRUNC('day', paid_at) AS booking__paid_at__day - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', paid_at) ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time_quarter__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time_quarter__plan0.sql index 0ee263acd6..9e0ddf7c7a 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time_quarter__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time_quarter__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY subq_0.booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time_quarter__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time_quarter__plan0_optimized.sql index f6d583edbe..5ff0fa4feb 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time_quarter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_min_max_only_time_quarter__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__quarter',] SELECT DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('quarter', paid_at) ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql index cdf345df4c..2b94c491ad 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__user__home_state_latest - , subq_10.bookings + subq_23.metric_time__day + , subq_23.listing__user__home_state_latest + , subq_23.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest - , SUM(subq_9.bookings) AS bookings + subq_22.metric_time__day + , subq_22.listing__user__home_state_latest + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__home_state_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__user__home_state_latest - , subq_8.bookings + subq_21.metric_time__day + , subq_21.listing__user__home_state_latest + , subq_21.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.window_start__day AS listing__window_start__day - , subq_7.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_7.user__home_state_latest AS listing__user__home_state_latest - , subq_2.bookings AS bookings + subq_15.metric_time__day AS metric_time__day + , subq_20.window_start__day AS listing__window_start__day + , subq_20.window_end__day AS listing__window_end__day + , subq_15.listing AS listing + , subq_20.user__home_state_latest AS listing__user__home_state_latest + , subq_15.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_14.metric_time__day + , subq_14.listing + , subq_14.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.user + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.booking__user + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.bookers + , subq_13.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,142 +211,142 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_13 + ) subq_14 + ) subq_15 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_6.window_start__day - , subq_6.window_end__day - , subq_6.listing - , subq_6.user__home_state_latest + subq_19.window_start__day + , subq_19.window_end__day + , subq_19.listing + , subq_19.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_3.window_start__day AS window_start__day - , subq_3.window_start__week AS window_start__week - , subq_3.window_start__month AS window_start__month - , subq_3.window_start__quarter AS window_start__quarter - , subq_3.window_start__year AS window_start__year - , subq_3.window_start__extract_year AS window_start__extract_year - , subq_3.window_start__extract_quarter AS window_start__extract_quarter - , subq_3.window_start__extract_month AS window_start__extract_month - , subq_3.window_start__extract_day AS window_start__extract_day - , subq_3.window_start__extract_dow AS window_start__extract_dow - , subq_3.window_start__extract_doy AS window_start__extract_doy - , subq_3.window_end__day AS window_end__day - , subq_3.window_end__week AS window_end__week - , subq_3.window_end__month AS window_end__month - , subq_3.window_end__quarter AS window_end__quarter - , subq_3.window_end__year AS window_end__year - , subq_3.window_end__extract_year AS window_end__extract_year - , subq_3.window_end__extract_quarter AS window_end__extract_quarter - , subq_3.window_end__extract_month AS window_end__extract_month - , subq_3.window_end__extract_day AS window_end__extract_day - , subq_3.window_end__extract_dow AS window_end__extract_dow - , subq_3.window_end__extract_doy AS window_end__extract_doy - , subq_3.listing__window_start__day AS listing__window_start__day - , subq_3.listing__window_start__week AS listing__window_start__week - , subq_3.listing__window_start__month AS listing__window_start__month - , subq_3.listing__window_start__quarter AS listing__window_start__quarter - , subq_3.listing__window_start__year AS listing__window_start__year - , subq_3.listing__window_start__extract_year AS listing__window_start__extract_year - , subq_3.listing__window_start__extract_quarter AS listing__window_start__extract_quarter - , subq_3.listing__window_start__extract_month AS listing__window_start__extract_month - , subq_3.listing__window_start__extract_day AS listing__window_start__extract_day - , subq_3.listing__window_start__extract_dow AS listing__window_start__extract_dow - , subq_3.listing__window_start__extract_doy AS listing__window_start__extract_doy - , subq_3.listing__window_end__day AS listing__window_end__day - , subq_3.listing__window_end__week AS listing__window_end__week - , subq_3.listing__window_end__month AS listing__window_end__month - , subq_3.listing__window_end__quarter AS listing__window_end__quarter - , subq_3.listing__window_end__year AS listing__window_end__year - , subq_3.listing__window_end__extract_year AS listing__window_end__extract_year - , subq_3.listing__window_end__extract_quarter AS listing__window_end__extract_quarter - , subq_3.listing__window_end__extract_month AS listing__window_end__extract_month - , subq_3.listing__window_end__extract_day AS listing__window_end__extract_day - , subq_3.listing__window_end__extract_dow AS listing__window_end__extract_dow - , subq_3.listing__window_end__extract_doy AS listing__window_end__extract_doy - , subq_5.ds__day AS user__ds__day - , subq_5.ds__week AS user__ds__week - , subq_5.ds__month AS user__ds__month - , subq_5.ds__quarter AS user__ds__quarter - , subq_5.ds__year AS user__ds__year - , subq_5.ds__extract_year AS user__ds__extract_year - , subq_5.ds__extract_quarter AS user__ds__extract_quarter - , subq_5.ds__extract_month AS user__ds__extract_month - , subq_5.ds__extract_day AS user__ds__extract_day - , subq_5.ds__extract_dow AS user__ds__extract_dow - , subq_5.ds__extract_doy AS user__ds__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country AS country - , subq_3.is_lux AS is_lux - , subq_3.capacity AS capacity - , subq_3.listing__country AS listing__country - , subq_3.listing__is_lux AS listing__is_lux - , subq_3.listing__capacity AS listing__capacity - , subq_5.home_state_latest AS user__home_state_latest + subq_16.window_start__day AS window_start__day + , subq_16.window_start__week AS window_start__week + , subq_16.window_start__month AS window_start__month + , subq_16.window_start__quarter AS window_start__quarter + , subq_16.window_start__year AS window_start__year + , subq_16.window_start__extract_year AS window_start__extract_year + , subq_16.window_start__extract_quarter AS window_start__extract_quarter + , subq_16.window_start__extract_month AS window_start__extract_month + , subq_16.window_start__extract_day AS window_start__extract_day + , subq_16.window_start__extract_dow AS window_start__extract_dow + , subq_16.window_start__extract_doy AS window_start__extract_doy + , subq_16.window_end__day AS window_end__day + , subq_16.window_end__week AS window_end__week + , subq_16.window_end__month AS window_end__month + , subq_16.window_end__quarter AS window_end__quarter + , subq_16.window_end__year AS window_end__year + , subq_16.window_end__extract_year AS window_end__extract_year + , subq_16.window_end__extract_quarter AS window_end__extract_quarter + , subq_16.window_end__extract_month AS window_end__extract_month + , subq_16.window_end__extract_day AS window_end__extract_day + , subq_16.window_end__extract_dow AS window_end__extract_dow + , subq_16.window_end__extract_doy AS window_end__extract_doy + , subq_16.listing__window_start__day AS listing__window_start__day + , subq_16.listing__window_start__week AS listing__window_start__week + , subq_16.listing__window_start__month AS listing__window_start__month + , subq_16.listing__window_start__quarter AS listing__window_start__quarter + , subq_16.listing__window_start__year AS listing__window_start__year + , subq_16.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_16.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_16.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_16.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_16.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_16.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_16.listing__window_end__day AS listing__window_end__day + , subq_16.listing__window_end__week AS listing__window_end__week + , subq_16.listing__window_end__month AS listing__window_end__month + , subq_16.listing__window_end__quarter AS listing__window_end__quarter + , subq_16.listing__window_end__year AS listing__window_end__year + , subq_16.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_16.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_16.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_16.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_16.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_16.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_18.ds__day AS user__ds__day + , subq_18.ds__week AS user__ds__week + , subq_18.ds__month AS user__ds__month + , subq_18.ds__quarter AS user__ds__quarter + , subq_18.ds__year AS user__ds__year + , subq_18.ds__extract_year AS user__ds__extract_year + , subq_18.ds__extract_quarter AS user__ds__extract_quarter + , subq_18.ds__extract_month AS user__ds__extract_month + , subq_18.ds__extract_day AS user__ds__extract_day + , subq_18.ds__extract_dow AS user__ds__extract_dow + , subq_18.ds__extract_doy AS user__ds__extract_doy + , subq_16.listing AS listing + , subq_16.user AS user + , subq_16.listing__user AS listing__user + , subq_16.country AS country + , subq_16.is_lux AS is_lux + , subq_16.capacity AS capacity + , subq_16.listing__country AS listing__country + , subq_16.listing__is_lux AS listing__is_lux + , subq_16.listing__capacity AS listing__capacity + , subq_18.home_state_latest AS user__home_state_latest FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , EXTRACT(dayofweekiso FROM listings_src_26002.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , EXTRACT(dayofweekiso FROM listings_src_26002.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , EXTRACT(dayofweekiso FROM listings_src_26002.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , EXTRACT(dayofweekiso FROM listings_src_26002.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , EXTRACT(dayofweekiso FROM listings_src_26000.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , EXTRACT(dayofweekiso FROM listings_src_26000.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , EXTRACT(dayofweekiso FROM listings_src_26000.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , EXTRACT(dayofweekiso FROM listings_src_26000.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_16 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,83 +376,83 @@ FROM ( -- 'user', -- ] SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.user__ds__day - , subq_4.user__ds__week - , subq_4.user__ds__month - , subq_4.user__ds__quarter - , subq_4.user__ds__year - , subq_4.user__ds__extract_year - , subq_4.user__ds__extract_quarter - , subq_4.user__ds__extract_month - , subq_4.user__ds__extract_day - , subq_4.user__ds__extract_dow - , subq_4.user__ds__extract_doy - , subq_4.user - , subq_4.home_state_latest - , subq_4.user__home_state_latest + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.user__ds__day + , subq_17.user__ds__week + , subq_17.user__ds__month + , subq_17.user__ds__quarter + , subq_17.user__ds__year + , subq_17.user__ds__extract_year + , subq_17.user__ds__extract_quarter + , subq_17.user__ds__extract_month + , subq_17.user__ds__extract_day + , subq_17.user__ds__extract_dow + , subq_17.user__ds__extract_doy + , subq_17.user + , subq_17.home_state_latest + , subq_17.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_26006.ds) AS ds__day - , DATE_TRUNC('week', users_latest_src_26006.ds) AS ds__week - , DATE_TRUNC('month', users_latest_src_26006.ds) AS ds__month - , DATE_TRUNC('quarter', users_latest_src_26006.ds) AS ds__quarter - , DATE_TRUNC('year', users_latest_src_26006.ds) AS ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_26006.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_latest_src_26006.ds) AS ds__extract_doy - , users_latest_src_26006.home_state_latest - , DATE_TRUNC('day', users_latest_src_26006.ds) AS user__ds__day - , DATE_TRUNC('week', users_latest_src_26006.ds) AS user__ds__week - , DATE_TRUNC('month', users_latest_src_26006.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_latest_src_26006.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_latest_src_26006.ds) AS user__ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS user__ds__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_26006.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_latest_src_26006.ds) AS user__ds__extract_doy - , users_latest_src_26006.home_state_latest AS user__home_state_latest - , users_latest_src_26006.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_26006 - ) subq_4 - ) subq_5 + DATE_TRUNC('day', users_latest_src_26000.ds) AS ds__day + , DATE_TRUNC('week', users_latest_src_26000.ds) AS ds__week + , DATE_TRUNC('month', users_latest_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', users_latest_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', users_latest_src_26000.ds) AS ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_latest_src_26000.ds) AS ds__extract_doy + , users_latest_src_26000.home_state_latest + , DATE_TRUNC('day', users_latest_src_26000.ds) AS user__ds__day + , DATE_TRUNC('week', users_latest_src_26000.ds) AS user__ds__week + , DATE_TRUNC('month', users_latest_src_26000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_latest_src_26000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_latest_src_26000.ds) AS user__ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS user__ds__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_26000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_latest_src_26000.ds) AS user__ds__extract_doy + , users_latest_src_26000.home_state_latest AS user__home_state_latest + , users_latest_src_26000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_26000 + ) subq_17 + ) subq_18 ON - subq_3.user = subq_5.user - ) subq_6 - ) subq_7 + subq_16.user = subq_18.user + ) subq_19 + ) subq_20 ON ( - subq_2.listing = subq_7.listing + subq_15.listing = subq_20.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.window_start__day + subq_15.metric_time__day >= subq_20.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.window_end__day + subq_15.metric_time__day < subq_20.window_end__day ) OR ( - subq_7.window_end__day IS NULL + subq_20.window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_21 + ) subq_22 GROUP BY - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest -) subq_10 + subq_22.metric_time__day + , subq_22.listing__user__home_state_latest +) subq_23 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 1d7e6c24a7..f38afda4f7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.user__home_state_latest AS listing__user__home_state_latest - , SUM(subq_13.bookings) AS bookings + subq_26.metric_time__day AS metric_time__day + , subq_31.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_26.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,35 +15,35 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_26 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - listings_src_26002.active_from AS window_start__day - , listings_src_26002.active_to AS window_end__day - , listings_src_26002.listing_id AS listing - , users_latest_src_26006.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings listings_src_26002 + listings_src_26000.active_from AS window_start__day + , listings_src_26000.active_to AS window_end__day + , listings_src_26000.listing_id AS listing + , users_latest_src_26000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings listings_src_26000 LEFT OUTER JOIN - ***************************.dim_users_latest users_latest_src_26006 + ***************************.dim_users_latest users_latest_src_26000 ON - listings_src_26002.user_id = users_latest_src_26006.user_id -) subq_18 + listings_src_26000.user_id = users_latest_src_26000.user_id +) subq_31 ON ( - subq_13.listing = subq_18.listing + subq_26.listing = subq_31.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_26.metric_time__day >= subq_31.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_26.metric_time__day < subq_31.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_31.window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.user__home_state_latest + subq_26.metric_time__day + , subq_31.user__home_state_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql index eeb60f62b4..956d9743be 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__lux_listing__is_confirmed_lux - , subq_10.bookings + subq_15.metric_time__day + , subq_15.listing__lux_listing__is_confirmed_lux + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux - , SUM(subq_9.bookings) AS bookings + subq_14.metric_time__day + , subq_14.listing__lux_listing__is_confirmed_lux + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__lux_listing__is_confirmed_lux', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__lux_listing__is_confirmed_lux - , subq_8.bookings + subq_13.metric_time__day + , subq_13.listing__lux_listing__is_confirmed_lux + , subq_13.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.lux_listing__window_start__day AS listing__lux_listing__window_start__day - , subq_7.lux_listing__window_end__day AS listing__lux_listing__window_end__day - , subq_2.listing AS listing - , subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , subq_2.bookings AS bookings + subq_7.metric_time__day AS metric_time__day + , subq_12.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_12.lux_listing__window_end__day AS listing__lux_listing__window_end__day + , subq_7.listing AS listing + , subq_12.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_7.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_6.metric_time__day + , subq_6.listing + , subq_6.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.ds__day AS metric_time__day + , subq_5.ds__week AS metric_time__week + , subq_5.ds__month AS metric_time__month + , subq_5.ds__quarter AS metric_time__quarter + , subq_5.ds__year AS metric_time__year + , subq_5.ds__extract_year AS metric_time__extract_year + , subq_5.ds__extract_quarter AS metric_time__extract_quarter + , subq_5.ds__extract_month AS metric_time__extract_month + , subq_5.ds__extract_day AS metric_time__extract_day + , subq_5.ds__extract_dow AS metric_time__extract_dow + , subq_5.ds__extract_doy AS metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.user + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.booking__user + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.bookings + , subq_5.instant_bookings + , subq_5.booking_value + , subq_5.bookers + , subq_5.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,53 +211,53 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_5 + ) subq_6 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - subq_6.lux_listing__window_start__day - , subq_6.lux_listing__window_end__day - , subq_6.listing - , subq_6.lux_listing__is_confirmed_lux + subq_11.lux_listing__window_start__day + , subq_11.lux_listing__window_end__day + , subq_11.listing + , subq_11.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_5.window_start__day AS lux_listing__window_start__day - , subq_5.window_start__week AS lux_listing__window_start__week - , subq_5.window_start__month AS lux_listing__window_start__month - , subq_5.window_start__quarter AS lux_listing__window_start__quarter - , subq_5.window_start__year AS lux_listing__window_start__year - , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_5.window_end__day AS lux_listing__window_end__day - , subq_5.window_end__week AS lux_listing__window_end__week - , subq_5.window_end__month AS lux_listing__window_end__month - , subq_5.window_end__quarter AS lux_listing__window_end__quarter - , subq_5.window_end__year AS lux_listing__window_end__year - , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_3.listing AS listing - , subq_3.lux_listing AS lux_listing - , subq_3.listing__lux_listing AS listing__lux_listing - , subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux + subq_10.window_start__day AS lux_listing__window_start__day + , subq_10.window_start__week AS lux_listing__window_start__week + , subq_10.window_start__month AS lux_listing__window_start__month + , subq_10.window_start__quarter AS lux_listing__window_start__quarter + , subq_10.window_start__year AS lux_listing__window_start__year + , subq_10.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_10.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_10.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_10.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_10.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_10.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_10.window_end__day AS lux_listing__window_end__day + , subq_10.window_end__week AS lux_listing__window_end__week + , subq_10.window_end__month AS lux_listing__window_end__month + , subq_10.window_end__quarter AS lux_listing__window_end__quarter + , subq_10.window_end__year AS lux_listing__window_end__year + , subq_10.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_10.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_10.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_10.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_10.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_10.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_8.listing AS listing + , subq_8.lux_listing AS lux_listing + , subq_8.listing__lux_listing AS listing__lux_listing + , subq_10.is_confirmed_lux AS lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT - lux_listing_mapping_src_26003.listing_id AS listing - , lux_listing_mapping_src_26003.lux_listing_id AS lux_listing - , lux_listing_mapping_src_26003.lux_listing_id AS listing__lux_listing - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 - ) subq_3 + lux_listing_mapping_src_26000.listing_id AS listing + , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing + , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 + ) subq_8 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,127 +309,127 @@ FROM ( -- 'lux_listing', -- ] SELECT - subq_4.window_start__day - , subq_4.window_start__week - , subq_4.window_start__month - , subq_4.window_start__quarter - , subq_4.window_start__year - , subq_4.window_start__extract_year - , subq_4.window_start__extract_quarter - , subq_4.window_start__extract_month - , subq_4.window_start__extract_day - , subq_4.window_start__extract_dow - , subq_4.window_start__extract_doy - , subq_4.window_end__day - , subq_4.window_end__week - , subq_4.window_end__month - , subq_4.window_end__quarter - , subq_4.window_end__year - , subq_4.window_end__extract_year - , subq_4.window_end__extract_quarter - , subq_4.window_end__extract_month - , subq_4.window_end__extract_day - , subq_4.window_end__extract_dow - , subq_4.window_end__extract_doy - , subq_4.lux_listing__window_start__day - , subq_4.lux_listing__window_start__week - , subq_4.lux_listing__window_start__month - , subq_4.lux_listing__window_start__quarter - , subq_4.lux_listing__window_start__year - , subq_4.lux_listing__window_start__extract_year - , subq_4.lux_listing__window_start__extract_quarter - , subq_4.lux_listing__window_start__extract_month - , subq_4.lux_listing__window_start__extract_day - , subq_4.lux_listing__window_start__extract_dow - , subq_4.lux_listing__window_start__extract_doy - , subq_4.lux_listing__window_end__day - , subq_4.lux_listing__window_end__week - , subq_4.lux_listing__window_end__month - , subq_4.lux_listing__window_end__quarter - , subq_4.lux_listing__window_end__year - , subq_4.lux_listing__window_end__extract_year - , subq_4.lux_listing__window_end__extract_quarter - , subq_4.lux_listing__window_end__extract_month - , subq_4.lux_listing__window_end__extract_day - , subq_4.lux_listing__window_end__extract_dow - , subq_4.lux_listing__window_end__extract_doy - , subq_4.lux_listing - , subq_4.is_confirmed_lux - , subq_4.lux_listing__is_confirmed_lux + subq_9.window_start__day + , subq_9.window_start__week + , subq_9.window_start__month + , subq_9.window_start__quarter + , subq_9.window_start__year + , subq_9.window_start__extract_year + , subq_9.window_start__extract_quarter + , subq_9.window_start__extract_month + , subq_9.window_start__extract_day + , subq_9.window_start__extract_dow + , subq_9.window_start__extract_doy + , subq_9.window_end__day + , subq_9.window_end__week + , subq_9.window_end__month + , subq_9.window_end__quarter + , subq_9.window_end__year + , subq_9.window_end__extract_year + , subq_9.window_end__extract_quarter + , subq_9.window_end__extract_month + , subq_9.window_end__extract_day + , subq_9.window_end__extract_dow + , subq_9.window_end__extract_doy + , subq_9.lux_listing__window_start__day + , subq_9.lux_listing__window_start__week + , subq_9.lux_listing__window_start__month + , subq_9.lux_listing__window_start__quarter + , subq_9.lux_listing__window_start__year + , subq_9.lux_listing__window_start__extract_year + , subq_9.lux_listing__window_start__extract_quarter + , subq_9.lux_listing__window_start__extract_month + , subq_9.lux_listing__window_start__extract_day + , subq_9.lux_listing__window_start__extract_dow + , subq_9.lux_listing__window_start__extract_doy + , subq_9.lux_listing__window_end__day + , subq_9.lux_listing__window_end__week + , subq_9.lux_listing__window_end__month + , subq_9.lux_listing__window_end__quarter + , subq_9.lux_listing__window_end__year + , subq_9.lux_listing__window_end__extract_year + , subq_9.lux_listing__window_end__extract_quarter + , subq_9.lux_listing__window_end__extract_month + , subq_9.lux_listing__window_end__extract_day + , subq_9.lux_listing__window_end__extract_dow + , subq_9.lux_listing__window_end__extract_doy + , subq_9.lux_listing + , subq_9.is_confirmed_lux + , subq_9.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT - lux_listings_src_26004.valid_from AS window_start__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_from) AS window_start__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_from) AS window_start__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_from) AS window_start__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_from) AS window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS window_start__extract_day - , EXTRACT(dayofweekiso FROM lux_listings_src_26004.valid_from) AS window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_from) AS window_start__extract_doy - , lux_listings_src_26004.valid_to AS window_end__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_to) AS window_end__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_to) AS window_end__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_to) AS window_end__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_to) AS window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS window_end__extract_day - , EXTRACT(dayofweekiso FROM lux_listings_src_26004.valid_to) AS window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_to) AS window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux - , lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_from) AS lux_listing__window_start__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_from) AS lux_listing__window_start__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_from) AS lux_listing__window_start__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_from) AS lux_listing__window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_day - , EXTRACT(dayofweekiso FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_doy - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_to) AS lux_listing__window_end__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_to) AS lux_listing__window_end__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_to) AS lux_listing__window_end__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_to) AS lux_listing__window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_day - , EXTRACT(dayofweekiso FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - , lux_listings_src_26004.lux_listing_id AS lux_listing - FROM ***************************.dim_lux_listings lux_listings_src_26004 - ) subq_4 - ) subq_5 + lux_listings_src_26000.valid_from AS window_start__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_from) AS window_start__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_from) AS window_start__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_from) AS window_start__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_from) AS window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS window_start__extract_day + , EXTRACT(dayofweekiso FROM lux_listings_src_26000.valid_from) AS window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_from) AS window_start__extract_doy + , lux_listings_src_26000.valid_to AS window_end__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_to) AS window_end__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_to) AS window_end__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_to) AS window_end__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_to) AS window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS window_end__extract_day + , EXTRACT(dayofweekiso FROM lux_listings_src_26000.valid_to) AS window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_to) AS window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux + , lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_from) AS lux_listing__window_start__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_from) AS lux_listing__window_start__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_from) AS lux_listing__window_start__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_from) AS lux_listing__window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_day + , EXTRACT(dayofweekiso FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_doy + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_to) AS lux_listing__window_end__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_to) AS lux_listing__window_end__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_to) AS lux_listing__window_end__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_to) AS lux_listing__window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_day + , EXTRACT(dayofweekiso FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + , lux_listings_src_26000.lux_listing_id AS lux_listing + FROM ***************************.dim_lux_listings lux_listings_src_26000 + ) subq_9 + ) subq_10 ON - subq_3.lux_listing = subq_5.lux_listing - ) subq_6 - ) subq_7 + subq_8.lux_listing = subq_10.lux_listing + ) subq_11 + ) subq_12 ON ( - subq_2.listing = subq_7.listing + subq_7.listing = subq_12.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.lux_listing__window_start__day + subq_7.metric_time__day >= subq_12.lux_listing__window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.lux_listing__window_end__day + subq_7.metric_time__day < subq_12.lux_listing__window_end__day ) OR ( - subq_7.lux_listing__window_end__day IS NULL + subq_12.lux_listing__window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_13 + ) subq_14 GROUP BY - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux -) subq_10 + subq_14.metric_time__day + , subq_14.listing__lux_listing__is_confirmed_lux +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql index 0ef5f08ffa..eb9b15d13c 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , SUM(subq_13.bookings) AS bookings + subq_18.metric_time__day AS metric_time__day + , subq_23.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_18.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,35 +15,35 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_18 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , lux_listing_mapping_src_26003.listing_id AS listing - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 + lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , lux_listing_mapping_src_26000.listing_id AS listing + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 LEFT OUTER JOIN - ***************************.dim_lux_listings lux_listings_src_26004 + ***************************.dim_lux_listings lux_listings_src_26000 ON - lux_listing_mapping_src_26003.lux_listing_id = lux_listings_src_26004.lux_listing_id -) subq_18 + lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id +) subq_23 ON ( - subq_13.listing = subq_18.listing + subq_18.listing = subq_23.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.lux_listing__window_start__day + subq_18.metric_time__day >= subq_23.lux_listing__window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.lux_listing__window_end__day + subq_18.metric_time__day < subq_23.lux_listing__window_end__day ) OR ( - subq_18.lux_listing__window_end__day IS NULL + subq_23.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.lux_listing__is_confirmed_lux + subq_18.metric_time__day + , subq_23.lux_listing__is_confirmed_lux diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql index dc8bf96a93..bdcd02b119 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql @@ -1,93 +1,93 @@ -- Compute Metrics via Expressions SELECT - subq_10.account_id__customer_id__customer_name - , subq_10.txn_count + subq_14.account_id__customer_id__customer_name + , subq_14.txn_count FROM ( -- Aggregate Measures SELECT - subq_9.account_id__customer_id__customer_name - , SUM(subq_9.txn_count) AS txn_count + subq_13.account_id__customer_id__customer_name + , SUM(subq_13.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_8.account_id__customer_id__customer_name - , subq_8.txn_count + subq_12.account_id__customer_id__customer_name + , subq_12.txn_count FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_2.account_id AS account_id - , subq_7.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_2.txn_count AS txn_count + subq_6.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_6.account_id AS account_id + , subq_11.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_6.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_1.ds_partitioned__day - , subq_1.account_id - , subq_1.txn_count + subq_5.ds_partitioned__day + , subq_5.account_id + , subq_5.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.account_id__ds_partitioned__day - , subq_0.account_id__ds_partitioned__week - , subq_0.account_id__ds_partitioned__month - , subq_0.account_id__ds_partitioned__quarter - , subq_0.account_id__ds_partitioned__year - , subq_0.account_id__ds_partitioned__extract_year - , subq_0.account_id__ds_partitioned__extract_quarter - , subq_0.account_id__ds_partitioned__extract_month - , subq_0.account_id__ds_partitioned__extract_day - , subq_0.account_id__ds_partitioned__extract_dow - , subq_0.account_id__ds_partitioned__extract_doy - , subq_0.account_id__ds__day - , subq_0.account_id__ds__week - , subq_0.account_id__ds__month - , subq_0.account_id__ds__quarter - , subq_0.account_id__ds__year - , subq_0.account_id__ds__extract_year - , subq_0.account_id__ds__extract_quarter - , subq_0.account_id__ds__extract_month - , subq_0.account_id__ds__extract_day - , subq_0.account_id__ds__extract_dow - , subq_0.account_id__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.account_id - , subq_0.account_month - , subq_0.account_id__account_month - , subq_0.txn_count + subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.account_id__ds_partitioned__day + , subq_4.account_id__ds_partitioned__week + , subq_4.account_id__ds_partitioned__month + , subq_4.account_id__ds_partitioned__quarter + , subq_4.account_id__ds_partitioned__year + , subq_4.account_id__ds_partitioned__extract_year + , subq_4.account_id__ds_partitioned__extract_quarter + , subq_4.account_id__ds_partitioned__extract_month + , subq_4.account_id__ds_partitioned__extract_day + , subq_4.account_id__ds_partitioned__extract_dow + , subq_4.account_id__ds_partitioned__extract_doy + , subq_4.account_id__ds__day + , subq_4.account_id__ds__week + , subq_4.account_id__ds__month + , subq_4.account_id__ds__quarter + , subq_4.account_id__ds__year + , subq_4.account_id__ds__extract_year + , subq_4.account_id__ds__extract_quarter + , subq_4.account_id__ds__extract_month + , subq_4.account_id__ds__extract_day + , subq_4.account_id__ds__extract_dow + , subq_4.account_id__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.account_id + , subq_4.account_month + , subq_4.account_id__account_month + , subq_4.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -140,118 +140,118 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_4 + ) subq_5 + ) subq_6 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_6.ds_partitioned__day - , subq_6.account_id - , subq_6.customer_id__customer_name + subq_10.ds_partitioned__day + , subq_10.account_id + , subq_10.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_3.ds_partitioned__day AS ds_partitioned__day - , subq_3.ds_partitioned__week AS ds_partitioned__week - , subq_3.ds_partitioned__month AS ds_partitioned__month - , subq_3.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_3.ds_partitioned__year AS ds_partitioned__year - , subq_3.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_3.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_3.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_3.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_3.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_3.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_3.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_3.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_3.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_3.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_3.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_3.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_3.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_5.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_5.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_5.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_5.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_5.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_5.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_3.account_id AS account_id - , subq_3.customer_id AS customer_id - , subq_3.account_id__customer_id AS account_id__customer_id - , subq_3.bridge_account__account_id AS bridge_account__account_id - , subq_3.bridge_account__customer_id AS bridge_account__customer_id - , subq_3.extra_dim AS extra_dim - , subq_3.account_id__extra_dim AS account_id__extra_dim - , subq_3.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_5.customer_name AS customer_id__customer_name - , subq_5.customer_atomic_weight AS customer_id__customer_atomic_weight + subq_7.ds_partitioned__day AS ds_partitioned__day + , subq_7.ds_partitioned__week AS ds_partitioned__week + , subq_7.ds_partitioned__month AS ds_partitioned__month + , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_7.ds_partitioned__year AS ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_9.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_9.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_9.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_9.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_9.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_9.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_7.account_id AS account_id + , subq_7.customer_id AS customer_id + , subq_7.account_id__customer_id AS account_id__customer_id + , subq_7.bridge_account__account_id AS bridge_account__account_id + , subq_7.bridge_account__customer_id AS bridge_account__customer_id + , subq_7.extra_dim AS extra_dim + , subq_7.account_id__extra_dim AS account_id__extra_dim + , subq_7.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_9.customer_name AS customer_id__customer_name + , subq_9.customer_atomic_weight AS customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT - bridge_table_src_22001.extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS account_id__extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS bridge_account__extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy - , bridge_table_src_22001.account_id - , bridge_table_src_22001.customer_id - , bridge_table_src_22001.customer_id AS account_id__customer_id - , bridge_table_src_22001.account_id AS bridge_account__account_id - , bridge_table_src_22001.customer_id AS bridge_account__customer_id - FROM ***************************.bridge_table bridge_table_src_22001 - ) subq_3 + bridge_table_src_22000.extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS account_id__extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS bridge_account__extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy + , bridge_table_src_22000.account_id + , bridge_table_src_22000.customer_id + , bridge_table_src_22000.customer_id AS account_id__customer_id + , bridge_table_src_22000.account_id AS bridge_account__account_id + , bridge_table_src_22000.customer_id AS bridge_account__customer_id + FROM ***************************.bridge_table bridge_table_src_22000 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -283,82 +283,82 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.customer_id__ds_partitioned__day - , subq_4.customer_id__ds_partitioned__week - , subq_4.customer_id__ds_partitioned__month - , subq_4.customer_id__ds_partitioned__quarter - , subq_4.customer_id__ds_partitioned__year - , subq_4.customer_id__ds_partitioned__extract_year - , subq_4.customer_id__ds_partitioned__extract_quarter - , subq_4.customer_id__ds_partitioned__extract_month - , subq_4.customer_id__ds_partitioned__extract_day - , subq_4.customer_id__ds_partitioned__extract_dow - , subq_4.customer_id__ds_partitioned__extract_doy - , subq_4.customer_id - , subq_4.customer_name - , subq_4.customer_atomic_weight - , subq_4.customer_id__customer_name - , subq_4.customer_id__customer_atomic_weight + subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.customer_id__ds_partitioned__day + , subq_8.customer_id__ds_partitioned__week + , subq_8.customer_id__ds_partitioned__month + , subq_8.customer_id__ds_partitioned__quarter + , subq_8.customer_id__ds_partitioned__year + , subq_8.customer_id__ds_partitioned__extract_year + , subq_8.customer_id__ds_partitioned__extract_quarter + , subq_8.customer_id__ds_partitioned__extract_month + , subq_8.customer_id__ds_partitioned__extract_day + , subq_8.customer_id__ds_partitioned__extract_dow + , subq_8.customer_id__ds_partitioned__extract_doy + , subq_8.customer_id + , subq_8.customer_name + , subq_8.customer_atomic_weight + , subq_8.customer_id__customer_name + , subq_8.customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT - customer_table_src_22003.customer_name - , customer_table_src_22003.customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_22003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_22003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_22003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_22003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_doy - , customer_table_src_22003.customer_name AS customer_id__customer_name - , customer_table_src_22003.customer_atomic_weight AS customer_id__customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_doy - , customer_table_src_22003.customer_id - FROM ***************************.customer_table customer_table_src_22003 - ) subq_4 - ) subq_5 + customer_table_src_22000.customer_name + , customer_table_src_22000.customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , customer_table_src_22000.customer_name AS customer_id__customer_name + , customer_table_src_22000.customer_atomic_weight AS customer_id__customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy + , customer_table_src_22000.customer_id + FROM ***************************.customer_table customer_table_src_22000 + ) subq_8 + ) subq_9 ON ( - subq_3.customer_id = subq_5.customer_id + subq_7.customer_id = subq_9.customer_id ) AND ( - subq_3.ds_partitioned__day = subq_5.ds_partitioned__day + subq_7.ds_partitioned__day = subq_9.ds_partitioned__day ) - ) subq_6 - ) subq_7 + ) subq_10 + ) subq_11 ON ( - subq_2.account_id = subq_7.account_id + subq_6.account_id = subq_11.account_id ) AND ( - subq_2.ds_partitioned__day = subq_7.ds_partitioned__day + subq_6.ds_partitioned__day = subq_11.ds_partitioned__day ) - ) subq_8 - ) subq_9 + ) subq_12 + ) subq_13 GROUP BY - subq_9.account_id__customer_id__customer_name -) subq_10 + subq_13.account_id__customer_id__customer_name +) subq_14 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql index 7802d2f867..13473156ca 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql @@ -3,31 +3,31 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_18.customer_id__customer_name AS account_id__customer_id__customer_name + subq_22.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__day - , bridge_table_src_22001.account_id AS account_id - , customer_table_src_22003.customer_name AS customer_id__customer_name - FROM ***************************.bridge_table bridge_table_src_22001 + DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__day + , bridge_table_src_22000.account_id AS account_id + , customer_table_src_22000.customer_name AS customer_id__customer_name + FROM ***************************.bridge_table bridge_table_src_22000 LEFT OUTER JOIN - ***************************.customer_table customer_table_src_22003 + ***************************.customer_table customer_table_src_22000 ON ( - bridge_table_src_22001.customer_id = customer_table_src_22003.customer_id + bridge_table_src_22000.customer_id = customer_table_src_22000.customer_id ) AND ( - DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) + DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_18 +) subq_22 ON ( - account_month_txns_src_22000.account_id = subq_18.account_id + account_month_txns_src_22000.account_id = subq_22.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day ) GROUP BY - subq_18.customer_id__customer_name + subq_22.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql index 02bc987ced..af6f19e0b8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql @@ -1,536 +1,536 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_5.bookings) AS bookings - , MAX(subq_11.listings) AS listings + MAX(subq_18.bookings) AS bookings + , MAX(subq_24.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_4.bookings + subq_17.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_3.bookings) AS bookings + SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_2.bookings + subq_15.bookings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.ds_partitioned__day - , subq_1.ds_partitioned__week - , subq_1.ds_partitioned__month - , subq_1.ds_partitioned__quarter - , subq_1.ds_partitioned__year - , subq_1.ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy - , subq_1.paid_at__day - , subq_1.paid_at__week - , subq_1.paid_at__month - , subq_1.paid_at__quarter - , subq_1.paid_at__year - , subq_1.paid_at__extract_year - , subq_1.paid_at__extract_quarter - , subq_1.paid_at__extract_month - , subq_1.paid_at__extract_day - , subq_1.paid_at__extract_dow - , subq_1.paid_at__extract_doy - , subq_1.booking__ds__day - , subq_1.booking__ds__week - , subq_1.booking__ds__month - , subq_1.booking__ds__quarter - , subq_1.booking__ds__year - , subq_1.booking__ds__extract_year - , subq_1.booking__ds__extract_quarter - , subq_1.booking__ds__extract_month - , subq_1.booking__ds__extract_day - , subq_1.booking__ds__extract_dow - , subq_1.booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day - , subq_1.booking__paid_at__week - , subq_1.booking__paid_at__month - , subq_1.booking__paid_at__quarter - , subq_1.booking__paid_at__year - , subq_1.booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.listing - , subq_1.guest - , subq_1.host - , subq_1.booking__listing - , subq_1.booking__guest - , subq_1.booking__host - , subq_1.is_instant - , subq_1.booking__is_instant - , subq_1.bookings - , subq_1.instant_bookings - , subq_1.booking_value - , subq_1.max_booking_value - , subq_1.min_booking_value - , subq_1.bookers - , subq_1.average_booking_value - , subq_1.referred_bookings - , subq_1.median_booking_value - , subq_1.booking_value_p99 - , subq_1.discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 + subq_14.ds__day + , subq_14.ds__week + , subq_14.ds__month + , subq_14.ds__quarter + , subq_14.ds__year + , subq_14.ds__extract_year + , subq_14.ds__extract_quarter + , subq_14.ds__extract_month + , subq_14.ds__extract_day + , subq_14.ds__extract_dow + , subq_14.ds__extract_doy + , subq_14.ds_partitioned__day + , subq_14.ds_partitioned__week + , subq_14.ds_partitioned__month + , subq_14.ds_partitioned__quarter + , subq_14.ds_partitioned__year + , subq_14.ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy + , subq_14.paid_at__day + , subq_14.paid_at__week + , subq_14.paid_at__month + , subq_14.paid_at__quarter + , subq_14.paid_at__year + , subq_14.paid_at__extract_year + , subq_14.paid_at__extract_quarter + , subq_14.paid_at__extract_month + , subq_14.paid_at__extract_day + , subq_14.paid_at__extract_dow + , subq_14.paid_at__extract_doy + , subq_14.booking__ds__day + , subq_14.booking__ds__week + , subq_14.booking__ds__month + , subq_14.booking__ds__quarter + , subq_14.booking__ds__year + , subq_14.booking__ds__extract_year + , subq_14.booking__ds__extract_quarter + , subq_14.booking__ds__extract_month + , subq_14.booking__ds__extract_day + , subq_14.booking__ds__extract_dow + , subq_14.booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day + , subq_14.booking__paid_at__week + , subq_14.booking__paid_at__month + , subq_14.booking__paid_at__quarter + , subq_14.booking__paid_at__year + , subq_14.booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy + , subq_14.metric_time__day + , subq_14.metric_time__week + , subq_14.metric_time__month + , subq_14.metric_time__quarter + , subq_14.metric_time__year + , subq_14.metric_time__extract_year + , subq_14.metric_time__extract_quarter + , subq_14.metric_time__extract_month + , subq_14.metric_time__extract_day + , subq_14.metric_time__extract_dow + , subq_14.metric_time__extract_doy + , subq_14.listing + , subq_14.guest + , subq_14.host + , subq_14.booking__listing + , subq_14.booking__guest + , subq_14.booking__host + , subq_14.is_instant + , subq_14.booking__is_instant + , subq_14.bookings + , subq_14.instant_bookings + , subq_14.booking_value + , subq_14.max_booking_value + , subq_14.min_booking_value + , subq_14.bookers + , subq_14.average_booking_value + , subq_14.referred_bookings + , subq_14.median_booking_value + , subq_14.booking_value_p99 + , subq_14.discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_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 + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.max_booking_value + , subq_13.min_booking_value + , subq_13.bookers + , subq_13.average_booking_value + , subq_13.referred_bookings + , subq_13.median_booking_value + , subq_13.booking_value_p99 + , subq_13.discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_2 - ) subq_3 - ) subq_4 -) subq_5 + , 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_13 + ) subq_14 + WHERE subq_14.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_15 + ) subq_16 + ) subq_17 +) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.listings + subq_23.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_9.listings) AS listings + SUM(subq_22.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_8.listings + subq_21.listings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] 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.created_at__day - , subq_7.created_at__week - , subq_7.created_at__month - , subq_7.created_at__quarter - , subq_7.created_at__year - , subq_7.created_at__extract_year - , subq_7.created_at__extract_quarter - , subq_7.created_at__extract_month - , subq_7.created_at__extract_day - , subq_7.created_at__extract_dow - , subq_7.created_at__extract_doy - , subq_7.listing__ds__day - , subq_7.listing__ds__week - , subq_7.listing__ds__month - , subq_7.listing__ds__quarter - , subq_7.listing__ds__year - , subq_7.listing__ds__extract_year - , subq_7.listing__ds__extract_quarter - , subq_7.listing__ds__extract_month - , subq_7.listing__ds__extract_day - , subq_7.listing__ds__extract_dow - , subq_7.listing__ds__extract_doy - , subq_7.listing__created_at__day - , subq_7.listing__created_at__week - , subq_7.listing__created_at__month - , subq_7.listing__created_at__quarter - , subq_7.listing__created_at__year - , subq_7.listing__created_at__extract_year - , subq_7.listing__created_at__extract_quarter - , subq_7.listing__created_at__extract_month - , subq_7.listing__created_at__extract_day - , subq_7.listing__created_at__extract_dow - , subq_7.listing__created_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.user - , subq_7.listing__user - , subq_7.country_latest - , subq_7.is_lux_latest - , subq_7.capacity_latest - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.listings - , subq_7.largest_listing - , subq_7.smallest_listing + 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.created_at__day + , subq_20.created_at__week + , subq_20.created_at__month + , subq_20.created_at__quarter + , subq_20.created_at__year + , subq_20.created_at__extract_year + , subq_20.created_at__extract_quarter + , subq_20.created_at__extract_month + , subq_20.created_at__extract_day + , subq_20.created_at__extract_dow + , subq_20.created_at__extract_doy + , subq_20.listing__ds__day + , subq_20.listing__ds__week + , subq_20.listing__ds__month + , subq_20.listing__ds__quarter + , subq_20.listing__ds__year + , subq_20.listing__ds__extract_year + , subq_20.listing__ds__extract_quarter + , subq_20.listing__ds__extract_month + , subq_20.listing__ds__extract_day + , subq_20.listing__ds__extract_dow + , subq_20.listing__ds__extract_doy + , subq_20.listing__created_at__day + , subq_20.listing__created_at__week + , subq_20.listing__created_at__month + , subq_20.listing__created_at__quarter + , subq_20.listing__created_at__year + , subq_20.listing__created_at__extract_year + , subq_20.listing__created_at__extract_quarter + , subq_20.listing__created_at__extract_month + , subq_20.listing__created_at__extract_day + , subq_20.listing__created_at__extract_dow + , subq_20.listing__created_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.user + , subq_20.listing__user + , subq_20.country_latest + , subq_20.is_lux_latest + , subq_20.capacity_latest + , subq_20.listing__country_latest + , subq_20.listing__is_lux_latest + , subq_20.listing__capacity_latest + , subq_20.listings + , subq_20.largest_listing + , subq_20.smallest_listing FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_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.created_at__day + , subq_19.created_at__week + , subq_19.created_at__month + , subq_19.created_at__quarter + , subq_19.created_at__year + , subq_19.created_at__extract_year + , subq_19.created_at__extract_quarter + , subq_19.created_at__extract_month + , subq_19.created_at__extract_day + , subq_19.created_at__extract_dow + , subq_19.created_at__extract_doy + , subq_19.listing__ds__day + , subq_19.listing__ds__week + , subq_19.listing__ds__month + , subq_19.listing__ds__quarter + , subq_19.listing__ds__year + , subq_19.listing__ds__extract_year + , subq_19.listing__ds__extract_quarter + , subq_19.listing__ds__extract_month + , subq_19.listing__ds__extract_day + , subq_19.listing__ds__extract_dow + , subq_19.listing__ds__extract_doy + , subq_19.listing__created_at__day + , subq_19.listing__created_at__week + , subq_19.listing__created_at__month + , subq_19.listing__created_at__quarter + , subq_19.listing__created_at__year + , subq_19.listing__created_at__extract_year + , subq_19.listing__created_at__extract_quarter + , subq_19.listing__created_at__extract_month + , subq_19.listing__created_at__extract_day + , subq_19.listing__created_at__extract_dow + , subq_19.listing__created_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.user + , subq_19.listing__user + , subq_19.country_latest + , subq_19.is_lux_latest + , subq_19.capacity_latest + , subq_19.listing__country_latest + , subq_19.listing__is_lux_latest + , subq_19.listing__capacity_latest + , subq_19.listings + , subq_19.largest_listing + , subq_19.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_6 - ) subq_7 - WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_8 - ) subq_9 - ) subq_10 -) subq_11 + , 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_19 + ) subq_20 + WHERE subq_20.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_21 + ) subq_22 + ) subq_23 +) subq_24 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 2691ca3c38..71a7d98121 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_17.bookings) AS bookings - , MAX(subq_23.listings) AS listings + MAX(subq_30.bookings) AS bookings + , MAX(subq_36.listings) AS listings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -11,9 +11,9 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_17 +) subq_30 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -23,6 +23,6 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_23 +) subq_36 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql index 23dde171d5..cf87c128c6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql @@ -1,241 +1,241 @@ -- Compute Metrics via Expressions SELECT - subq_7.user__home_state - , subq_7.identity_verifications + subq_16.user__home_state + , subq_16.identity_verifications FROM ( -- Aggregate Measures SELECT - subq_6.user__home_state - , SUM(subq_6.identity_verifications) AS identity_verifications + subq_15.user__home_state + , SUM(subq_15.identity_verifications) AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'user__home_state'] SELECT - subq_5.user__home_state - , subq_5.identity_verifications + subq_14.user__home_state + , subq_14.identity_verifications FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__day AS user__ds_partitioned__day - , subq_2.user AS user - , subq_4.home_state AS user__home_state - , subq_2.identity_verifications AS identity_verifications + subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__day AS user__ds_partitioned__day + , subq_11.user AS user + , subq_13.home_state AS user__home_state + , subq_11.identity_verifications AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT - subq_1.ds_partitioned__day - , subq_1.user - , subq_1.identity_verifications + subq_10.ds_partitioned__day + , subq_10.user + , subq_10.identity_verifications 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.verification__ds__day - , subq_0.verification__ds__week - , subq_0.verification__ds__month - , subq_0.verification__ds__quarter - , subq_0.verification__ds__year - , subq_0.verification__ds__extract_year - , subq_0.verification__ds__extract_quarter - , subq_0.verification__ds__extract_month - , subq_0.verification__ds__extract_day - , subq_0.verification__ds__extract_dow - , subq_0.verification__ds__extract_doy - , subq_0.verification__ds_partitioned__day - , subq_0.verification__ds_partitioned__week - , subq_0.verification__ds_partitioned__month - , subq_0.verification__ds_partitioned__quarter - , subq_0.verification__ds_partitioned__year - , subq_0.verification__ds_partitioned__extract_year - , subq_0.verification__ds_partitioned__extract_quarter - , subq_0.verification__ds_partitioned__extract_month - , subq_0.verification__ds_partitioned__extract_day - , subq_0.verification__ds_partitioned__extract_dow - , subq_0.verification__ds_partitioned__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.verification - , subq_0.user - , subq_0.verification__user - , subq_0.verification_type - , subq_0.verification__verification_type - , subq_0.identity_verifications + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.verification__ds__day + , subq_9.verification__ds__week + , subq_9.verification__ds__month + , subq_9.verification__ds__quarter + , subq_9.verification__ds__year + , subq_9.verification__ds__extract_year + , subq_9.verification__ds__extract_quarter + , subq_9.verification__ds__extract_month + , subq_9.verification__ds__extract_day + , subq_9.verification__ds__extract_dow + , subq_9.verification__ds__extract_doy + , subq_9.verification__ds_partitioned__day + , subq_9.verification__ds_partitioned__week + , subq_9.verification__ds_partitioned__month + , subq_9.verification__ds_partitioned__quarter + , subq_9.verification__ds_partitioned__year + , subq_9.verification__ds_partitioned__extract_year + , subq_9.verification__ds_partitioned__extract_quarter + , subq_9.verification__ds_partitioned__extract_month + , subq_9.verification__ds_partitioned__extract_day + , subq_9.verification__ds_partitioned__extract_dow + , subq_9.verification__ds_partitioned__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.verification + , subq_9.user + , subq_9.verification__user + , subq_9.verification_type + , subq_9.verification__verification_type + , subq_9.identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_28004.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_28004.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user - FROM ***************************.fct_id_verifications id_verifications_src_28004 - ) subq_0 - ) subq_1 - ) subq_2 + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_28000.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user + FROM ***************************.fct_id_verifications id_verifications_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state', 'ds_partitioned__day', 'user'] SELECT - subq_3.ds_partitioned__day - , subq_3.user - , subq_3.home_state + subq_12.ds_partitioned__day + , subq_12.user + , subq_12.home_state FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - DATE_TRUNC('day', users_ds_source_src_28008.ds) AS ds__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds) AS ds__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds) AS ds__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds) AS ds__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds) AS ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28008.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds) AS ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.created_at) AS created_at__day - , DATE_TRUNC('week', users_ds_source_src_28008.created_at) AS created_at__week - , DATE_TRUNC('month', users_ds_source_src_28008.created_at) AS created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.created_at) AS created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.created_at) AS created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28008.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.created_at) AS created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state - , DATE_TRUNC('day', users_ds_source_src_28008.ds) AS user__ds__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds) AS user__ds__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds) AS user__ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS user__ds__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28008.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds) AS user__ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.created_at) AS user__created_at__day - , DATE_TRUNC('week', users_ds_source_src_28008.created_at) AS user__created_at__week - , DATE_TRUNC('month', users_ds_source_src_28008.created_at) AS user__created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.created_at) AS user__created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.created_at) AS user__created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state AS user__home_state - , users_ds_source_src_28008.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28008 - ) subq_3 - ) subq_4 + DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_12 + ) subq_13 ON ( - subq_2.user = subq_4.user + subq_11.user = subq_13.user ) AND ( - subq_2.ds_partitioned__day = subq_4.ds_partitioned__day + subq_11.ds_partitioned__day = subq_13.ds_partitioned__day ) - ) subq_5 - ) subq_6 + ) subq_14 + ) subq_15 GROUP BY - subq_6.user__home_state -) subq_7 + subq_15.user__home_state +) subq_16 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql index 9f15f9bb3d..54ea641813 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql @@ -3,8 +3,8 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - users_ds_source_src_28008.home_state AS user__home_state - , SUM(subq_10.identity_verifications) AS identity_verifications + users_ds_source_src_28000.home_state AS user__home_state + , SUM(subq_19.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' -- Metric Time Dimension 'ds' @@ -13,15 +13,15 @@ FROM ( DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications - FROM ***************************.fct_id_verifications id_verifications_src_28004 -) subq_10 + FROM ***************************.fct_id_verifications id_verifications_src_28000 +) subq_19 LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_28008 + ***************************.dim_users users_ds_source_src_28000 ON ( - subq_10.user = users_ds_source_src_28008.user_id + subq_19.user = users_ds_source_src_28000.user_id ) AND ( - subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) + subq_19.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) ) GROUP BY - users_ds_source_src_28008.home_state + users_ds_source_src_28000.home_state diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_common_semantic_model__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_common_semantic_model__plan0.sql index aa2f51f006..395c81b881 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_common_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_common_semantic_model__plan0.sql @@ -1,439 +1,439 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , MAX(subq_4.bookings) AS bookings - , MAX(subq_9.booking_value) AS booking_value + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day + , MAX(subq_13.bookings) AS bookings + , MAX(subq_18.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 -) subq_4 + subq_11.metric_time__day + ) subq_12 +) subq_13 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_value) AS booking_value + subq_16.metric_time__day + , SUM(subq_16.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_value + subq_15.metric_time__day + , subq_15.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + subq_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 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_5 - ) subq_6 - ) subq_7 + , 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_14 + ) subq_15 + ) subq_16 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_16.metric_time__day + ) subq_17 +) subq_18 ON - subq_4.metric_time__day = subq_9.metric_time__day + subq_13.metric_time__day = subq_18.metric_time__day GROUP BY - COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) + COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_common_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_common_semantic_model__plan0_optimized.sql index ccc0d8cd89..7831d40fe6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_common_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_common_semantic_model__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) AS metric_time__day - , MAX(subq_14.bookings) AS bookings - , MAX(subq_19.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -16,11 +16,11 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_21 GROUP BY metric_time__day -) subq_14 +) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -30,11 +30,11 @@ FULL OUTER JOIN ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) -) subq_19 +) subq_28 ON - subq_14.metric_time__day = subq_19.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_14.metric_time__day, subq_19.metric_time__day) + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0.sql index 4d9264bf6f..955c17a477 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0.sql @@ -68,62 +68,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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_1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0_optimized.sql index 22b719da85..1653ada5bd 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_3 WHERE listing__country_latest = 'us' GROUP BY diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0.sql index 15f0673d4d..900c600c0c 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -1,383 +1,383 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_19.booking__is_instant + , subq_19.bookings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_18.booking__is_instant + , SUM(subq_18.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_17.booking__is_instant + , subq_17.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_16.booking__is_instant + , subq_16.listing__country_latest + , subq_16.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_15.booking__is_instant + , subq_15.listing__country_latest + , subq_15.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.country_latest AS listing__country_latest - , subq_2.bookings AS bookings + subq_11.listing AS listing + , subq_11.booking__is_instant AS booking__is_instant + , subq_14.country_latest AS listing__country_latest + , subq_11.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.listing + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_13.listing + , subq_13.country_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__country_latest = 'us' - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_18.booking__is_instant +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index fdbb61ce0e..433c9799b5 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28005.country AS listing__country_latest - , subq_13.bookings AS bookings + subq_22.booking__is_instant AS booking__is_instant + , listings_latest_src_28000.country AS listing__country_latest + , subq_22.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -20,13 +20,13 @@ FROM ( listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_13 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_22 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28005.listing_id -) subq_18 + subq_22.listing = listings_latest_src_28000.listing_id +) subq_27 WHERE listing__country_latest = 'us' GROUP BY booking__is_instant diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0.sql index 0684457d26..733ea2eac9 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0.sql @@ -1,139 +1,139 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS family_bookings + subq_11.metric_time__day + , subq_11.bookings AS family_bookings FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_10.metric_time__day + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.listing__capacity - , subq_6.bookings + subq_8.metric_time__day + , subq_8.listing__capacity + , subq_8.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_5.metric_time__day - , subq_5.listing__capacity - , subq_5.bookings + subq_7.metric_time__day + , subq_7.listing__capacity + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_4.window_start__day AS listing__window_start__day - , subq_4.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_4.capacity AS listing__capacity - , subq_2.bookings AS bookings + subq_4.metric_time__day AS metric_time__day + , subq_6.window_start__day AS listing__window_start__day + , subq_6.window_end__day AS listing__window_end__day + , subq_4.listing AS listing + , subq_6.capacity AS listing__capacity + , subq_4.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_3.metric_time__day + , subq_3.listing + , subq_3.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + 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.user + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.booking__user + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.bookers + , subq_2.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -220,94 +220,94 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_2 + ) subq_3 + ) subq_4 LEFT OUTER JOIN ( -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_3.window_start__day - , subq_3.window_end__day - , subq_3.listing - , subq_3.capacity + subq_5.window_start__day + , subq_5.window_end__day + , subq_5.listing + , subq_5.capacity FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_src_26002.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_src_26002.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_src_26002.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_src_26002.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 - ) subq_4 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_src_26000.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_src_26000.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_src_26000.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_src_26000.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_4.listing + subq_4.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_4.window_start__day + subq_4.metric_time__day >= subq_6.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_4.window_end__day + subq_4.metric_time__day < subq_6.window_end__day ) OR ( - subq_4.window_end__day IS NULL + subq_6.window_end__day IS NULL ) ) ) - ) subq_5 - ) subq_6 + ) subq_7 + ) subq_8 WHERE listing__capacity > 2 - ) subq_7 - ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_8.metric_time__day -) subq_9 + subq_10.metric_time__day +) subq_11 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0_optimized.sql index fc848091b1..0f3bd95cd6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] SELECT - subq_12.metric_time__day AS metric_time__day - , listings_src_26002.capacity AS listing__capacity - , subq_12.bookings AS bookings + subq_14.metric_time__day AS metric_time__day + , listings_src_26000.capacity AS listing__capacity + , subq_14.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -21,24 +21,24 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_12 + ) subq_14 LEFT OUTER JOIN - ***************************.dim_listings listings_src_26002 + ***************************.dim_listings listings_src_26000 ON ( - subq_12.listing = listings_src_26002.listing_id + subq_14.listing = listings_src_26000.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_26002.active_from + subq_14.metric_time__day >= listings_src_26000.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_26002.active_to + subq_14.metric_time__day < listings_src_26000.active_to ) OR ( - listings_src_26002.active_to IS NULL + listings_src_26000.active_to IS NULL ) ) ) -) subq_16 +) subq_18 WHERE listing__capacity > 2 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_limit_rows__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_limit_rows__plan0.sql index 06cdb8896b..a87e1d7578 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_limit_rows__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_limit_rows__plan0.sql @@ -1,220 +1,220 @@ -- Order By [] Limit 1 SELECT - subq_4.ds__day - , subq_4.bookings + subq_13.ds__day + , subq_13.bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.ds__day - , subq_3.bookings + subq_12.ds__day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_2.ds__day - , SUM(subq_2.bookings) AS bookings + subq_11.ds__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'ds__day'] SELECT - subq_1.ds__day - , subq_1.bookings + subq_10.ds__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.ds__day - ) subq_3 -) subq_4 + subq_11.ds__day + ) subq_12 +) subq_13 LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_limit_rows__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_limit_rows__plan0_optimized.sql index a71f7ae0e8..0780ad9c07 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_limit_rows__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_limit_rows__plan0_optimized.sql @@ -11,8 +11,8 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_7 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_16 GROUP BY ds__day LIMIT 1 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_local_dimension_using_local_entity__plan0.sql index cfc58a123a..613b09fd34 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_local_dimension_using_local_entity__plan0.sql @@ -1,150 +1,150 @@ -- Compute Metrics via Expressions SELECT - subq_3.listing__country_latest - , subq_3.listings + subq_12.listing__country_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_2.listing__country_latest - , SUM(subq_2.listings) AS listings + subq_11.listing__country_latest + , SUM(subq_11.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'listing__country_latest'] SELECT - subq_1.listing__country_latest - , subq_1.listings + subq_10.listing__country_latest + , subq_10.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.created_at__day - , subq_0.created_at__week - , subq_0.created_at__month - , subq_0.created_at__quarter - , subq_0.created_at__year - , subq_0.created_at__extract_year - , subq_0.created_at__extract_quarter - , subq_0.created_at__extract_month - , subq_0.created_at__extract_day - , subq_0.created_at__extract_dow - , subq_0.created_at__extract_doy - , subq_0.listing__ds__day - , subq_0.listing__ds__week - , subq_0.listing__ds__month - , subq_0.listing__ds__quarter - , subq_0.listing__ds__year - , subq_0.listing__ds__extract_year - , subq_0.listing__ds__extract_quarter - , subq_0.listing__ds__extract_month - , subq_0.listing__ds__extract_day - , subq_0.listing__ds__extract_dow - , subq_0.listing__ds__extract_doy - , subq_0.listing__created_at__day - , subq_0.listing__created_at__week - , subq_0.listing__created_at__month - , subq_0.listing__created_at__quarter - , subq_0.listing__created_at__year - , subq_0.listing__created_at__extract_year - , subq_0.listing__created_at__extract_quarter - , subq_0.listing__created_at__extract_month - , subq_0.listing__created_at__extract_day - , subq_0.listing__created_at__extract_dow - , subq_0.listing__created_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.user - , subq_0.listing__user - , subq_0.country_latest - , subq_0.is_lux_latest - , subq_0.capacity_latest - , subq_0.listing__country_latest - , subq_0.listing__is_lux_latest - , subq_0.listing__capacity_latest - , subq_0.listings - , subq_0.largest_listing - , subq_0.smallest_listing + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.created_at__day + , subq_9.created_at__week + , subq_9.created_at__month + , subq_9.created_at__quarter + , subq_9.created_at__year + , subq_9.created_at__extract_year + , subq_9.created_at__extract_quarter + , subq_9.created_at__extract_month + , subq_9.created_at__extract_day + , subq_9.created_at__extract_dow + , subq_9.created_at__extract_doy + , subq_9.listing__ds__day + , subq_9.listing__ds__week + , subq_9.listing__ds__month + , subq_9.listing__ds__quarter + , subq_9.listing__ds__year + , subq_9.listing__ds__extract_year + , subq_9.listing__ds__extract_quarter + , subq_9.listing__ds__extract_month + , subq_9.listing__ds__extract_day + , subq_9.listing__ds__extract_dow + , subq_9.listing__ds__extract_doy + , subq_9.listing__created_at__day + , subq_9.listing__created_at__week + , subq_9.listing__created_at__month + , subq_9.listing__created_at__quarter + , subq_9.listing__created_at__year + , subq_9.listing__created_at__extract_year + , subq_9.listing__created_at__extract_quarter + , subq_9.listing__created_at__extract_month + , subq_9.listing__created_at__extract_day + , subq_9.listing__created_at__extract_dow + , subq_9.listing__created_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.user + , subq_9.listing__user + , subq_9.country_latest + , subq_9.is_lux_latest + , subq_9.capacity_latest + , subq_9.listing__country_latest + , subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.listings + , subq_9.largest_listing + , subq_9.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.listing__country_latest -) subq_3 + subq_11.listing__country_latest +) subq_12 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_local_dimension_using_local_entity__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_local_dimension_using_local_entity__plan0_optimized.sql index 8486e86449..c0733d39a6 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_local_dimension_using_local_entity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_local_dimension_using_local_entity__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( SELECT country AS listing__country_latest , 1 AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_6 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_15 GROUP BY listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0.sql index 2fde56482f..7944861221 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0.sql @@ -1,1003 +1,1003 @@ -- Compute Metrics via Expressions SELECT - subq_29.metric_time__day + subq_38.metric_time__day , average_booking_value * bookings / NULLIF(booking_value, 0) AS lux_booking_value_rate_expr FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , MAX(subq_11.average_booking_value) AS average_booking_value - , MAX(subq_23.bookings) AS bookings - , MAX(subq_28.booking_value) AS booking_value + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day, subq_37.metric_time__day) AS metric_time__day + , MAX(subq_20.average_booking_value) AS average_booking_value + , MAX(subq_32.bookings) AS bookings + , MAX(subq_37.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_19.metric_time__day + , subq_19.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , AVG(subq_9.average_booking_value) AS average_booking_value + subq_18.metric_time__day + , AVG(subq_18.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_17.metric_time__day + , subq_17.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.average_booking_value + subq_16.metric_time__day + , subq_16.listing__is_lux_latest + , subq_16.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_15.metric_time__day + , subq_15.listing__is_lux_latest + , subq_15.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.average_booking_value AS average_booking_value + subq_11.metric_time__day AS metric_time__day + , subq_11.listing AS listing + , subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.average_booking_value + subq_10.metric_time__day + , subq_10.listing + , subq_10.average_booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_13.listing + , subq_13.is_lux_latest 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.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.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.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_12.ds__day + , subq_12.ds__week + , subq_12.ds__month + , subq_12.ds__quarter + , subq_12.ds__year + , subq_12.ds__extract_year + , subq_12.ds__extract_quarter + , subq_12.ds__extract_month + , subq_12.ds__extract_day + , subq_12.ds__extract_dow + , subq_12.ds__extract_doy + , subq_12.created_at__day + , subq_12.created_at__week + , subq_12.created_at__month + , subq_12.created_at__quarter + , subq_12.created_at__year + , subq_12.created_at__extract_year + , subq_12.created_at__extract_quarter + , subq_12.created_at__extract_month + , subq_12.created_at__extract_day + , subq_12.created_at__extract_dow + , subq_12.created_at__extract_doy + , subq_12.listing__ds__day + , subq_12.listing__ds__week + , subq_12.listing__ds__month + , subq_12.listing__ds__quarter + , subq_12.listing__ds__year + , subq_12.listing__ds__extract_year + , subq_12.listing__ds__extract_quarter + , subq_12.listing__ds__extract_month + , subq_12.listing__ds__extract_day + , subq_12.listing__ds__extract_dow + , subq_12.listing__ds__extract_doy + , subq_12.listing__created_at__day + , subq_12.listing__created_at__week + , subq_12.listing__created_at__month + , subq_12.listing__created_at__quarter + , subq_12.listing__created_at__year + , subq_12.listing__created_at__extract_year + , subq_12.listing__created_at__extract_quarter + , subq_12.listing__created_at__extract_month + , subq_12.listing__created_at__extract_day + , subq_12.listing__created_at__extract_dow + , subq_12.listing__created_at__extract_doy + , subq_12.ds__day AS metric_time__day + , subq_12.ds__week AS metric_time__week + , subq_12.ds__month AS metric_time__month + , subq_12.ds__quarter AS metric_time__quarter + , subq_12.ds__year AS metric_time__year + , subq_12.ds__extract_year AS metric_time__extract_year + , subq_12.ds__extract_quarter AS metric_time__extract_quarter + , subq_12.ds__extract_month AS metric_time__extract_month + , subq_12.ds__extract_day AS metric_time__extract_day + , subq_12.ds__extract_dow AS metric_time__extract_dow + , subq_12.ds__extract_doy AS metric_time__extract_doy + , subq_12.listing + , subq_12.user + , subq_12.listing__user + , subq_12.country_latest + , subq_12.is_lux_latest + , subq_12.capacity_latest + , subq_12.listing__country_latest + , subq_12.listing__is_lux_latest + , subq_12.listing__capacity_latest + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_3 - ) subq_4 - ) subq_5 + , 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_12 + ) subq_13 + ) subq_14 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_11.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_17 + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_18.metric_time__day + ) subq_19 + ) subq_20 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day - , subq_22.bookings + subq_31.metric_time__day + , subq_31.bookings FROM ( -- Aggregate Measures SELECT - subq_21.metric_time__day - , SUM(subq_21.bookings) AS bookings + subq_30.metric_time__day + , SUM(subq_30.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_29.metric_time__day + , subq_29.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.bookings + subq_28.metric_time__day + , subq_28.listing__is_lux_latest + , subq_28.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_27.metric_time__day + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Join Standard Outputs SELECT - subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.bookings AS bookings + subq_23.metric_time__day AS metric_time__day + , subq_23.listing AS listing + , subq_26.is_lux_latest AS listing__is_lux_latest + , subq_23.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.bookings + subq_22.metric_time__day + , subq_22.listing + , subq_22.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.approximate_discrete_booking_value_p99 + subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.ds_partitioned__day + , subq_21.ds_partitioned__week + , subq_21.ds_partitioned__month + , subq_21.ds_partitioned__quarter + , subq_21.ds_partitioned__year + , subq_21.ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy + , subq_21.paid_at__day + , subq_21.paid_at__week + , subq_21.paid_at__month + , subq_21.paid_at__quarter + , subq_21.paid_at__year + , subq_21.paid_at__extract_year + , subq_21.paid_at__extract_quarter + , subq_21.paid_at__extract_month + , subq_21.paid_at__extract_day + , subq_21.paid_at__extract_dow + , subq_21.paid_at__extract_doy + , subq_21.booking__ds__day + , subq_21.booking__ds__week + , subq_21.booking__ds__month + , subq_21.booking__ds__quarter + , subq_21.booking__ds__year + , subq_21.booking__ds__extract_year + , subq_21.booking__ds__extract_quarter + , subq_21.booking__ds__extract_month + , subq_21.booking__ds__extract_day + , subq_21.booking__ds__extract_dow + , subq_21.booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day + , subq_21.booking__paid_at__week + , subq_21.booking__paid_at__month + , subq_21.booking__paid_at__quarter + , subq_21.booking__paid_at__year + , subq_21.booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy + , subq_21.ds__day AS metric_time__day + , subq_21.ds__week AS metric_time__week + , subq_21.ds__month AS metric_time__month + , subq_21.ds__quarter AS metric_time__quarter + , subq_21.ds__year AS metric_time__year + , subq_21.ds__extract_year AS metric_time__extract_year + , subq_21.ds__extract_quarter AS metric_time__extract_quarter + , subq_21.ds__extract_month AS metric_time__extract_month + , subq_21.ds__extract_day AS metric_time__extract_day + , subq_21.ds__extract_dow AS metric_time__extract_dow + , subq_21.ds__extract_doy AS metric_time__extract_doy + , subq_21.listing + , subq_21.guest + , subq_21.host + , subq_21.booking__listing + , subq_21.booking__guest + , subq_21.booking__host + , subq_21.is_instant + , subq_21.booking__is_instant + , subq_21.bookings + , subq_21.instant_bookings + , subq_21.booking_value + , subq_21.max_booking_value + , subq_21.min_booking_value + , subq_21.bookers + , subq_21.average_booking_value + , subq_21.referred_bookings + , subq_21.median_booking_value + , subq_21.booking_value_p99 + , subq_21.discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 + , subq_21.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_12 - ) subq_13 - ) subq_14 + , 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_21 + ) subq_22 + ) subq_23 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_16.listing - , subq_16.is_lux_latest + subq_25.listing + , subq_25.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.smallest_listing + subq_24.ds__day + , subq_24.ds__week + , subq_24.ds__month + , subq_24.ds__quarter + , subq_24.ds__year + , subq_24.ds__extract_year + , subq_24.ds__extract_quarter + , subq_24.ds__extract_month + , subq_24.ds__extract_day + , subq_24.ds__extract_dow + , subq_24.ds__extract_doy + , subq_24.created_at__day + , subq_24.created_at__week + , subq_24.created_at__month + , subq_24.created_at__quarter + , subq_24.created_at__year + , subq_24.created_at__extract_year + , subq_24.created_at__extract_quarter + , subq_24.created_at__extract_month + , subq_24.created_at__extract_day + , subq_24.created_at__extract_dow + , subq_24.created_at__extract_doy + , subq_24.listing__ds__day + , subq_24.listing__ds__week + , subq_24.listing__ds__month + , subq_24.listing__ds__quarter + , subq_24.listing__ds__year + , subq_24.listing__ds__extract_year + , subq_24.listing__ds__extract_quarter + , subq_24.listing__ds__extract_month + , subq_24.listing__ds__extract_day + , subq_24.listing__ds__extract_dow + , subq_24.listing__ds__extract_doy + , subq_24.listing__created_at__day + , subq_24.listing__created_at__week + , subq_24.listing__created_at__month + , subq_24.listing__created_at__quarter + , subq_24.listing__created_at__year + , subq_24.listing__created_at__extract_year + , subq_24.listing__created_at__extract_quarter + , subq_24.listing__created_at__extract_month + , subq_24.listing__created_at__extract_day + , subq_24.listing__created_at__extract_dow + , subq_24.listing__created_at__extract_doy + , subq_24.ds__day AS metric_time__day + , subq_24.ds__week AS metric_time__week + , subq_24.ds__month AS metric_time__month + , subq_24.ds__quarter AS metric_time__quarter + , subq_24.ds__year AS metric_time__year + , subq_24.ds__extract_year AS metric_time__extract_year + , subq_24.ds__extract_quarter AS metric_time__extract_quarter + , subq_24.ds__extract_month AS metric_time__extract_month + , subq_24.ds__extract_day AS metric_time__extract_day + , subq_24.ds__extract_dow AS metric_time__extract_dow + , subq_24.ds__extract_doy AS metric_time__extract_doy + , subq_24.listing + , subq_24.user + , subq_24.listing__user + , subq_24.country_latest + , subq_24.is_lux_latest + , subq_24.capacity_latest + , subq_24.listing__country_latest + , subq_24.listing__is_lux_latest + , subq_24.listing__capacity_latest + , subq_24.listings + , subq_24.largest_listing + , subq_24.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_15 - ) subq_16 - ) subq_17 + , 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_24 + ) subq_25 + ) subq_26 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_23.listing = subq_26.listing + ) subq_27 + ) subq_28 WHERE listing__is_lux_latest - ) subq_20 - ) subq_21 + ) subq_29 + ) subq_30 GROUP BY - subq_21.metric_time__day - ) subq_22 - ) subq_23 + subq_30.metric_time__day + ) subq_31 + ) subq_32 ON - subq_11.metric_time__day = subq_23.metric_time__day + subq_20.metric_time__day = subq_32.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.booking_value + subq_36.metric_time__day + , subq_36.booking_value FROM ( -- Aggregate Measures SELECT - subq_26.metric_time__day - , SUM(subq_26.booking_value) AS booking_value + subq_35.metric_time__day + , SUM(subq_35.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_25.metric_time__day - , subq_25.booking_value + subq_34.metric_time__day + , subq_34.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_24.ds__day - , subq_24.ds__week - , subq_24.ds__month - , subq_24.ds__quarter - , subq_24.ds__year - , subq_24.ds__extract_year - , subq_24.ds__extract_quarter - , subq_24.ds__extract_month - , subq_24.ds__extract_day - , subq_24.ds__extract_dow - , subq_24.ds__extract_doy - , subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.paid_at__day - , subq_24.paid_at__week - , subq_24.paid_at__month - , subq_24.paid_at__quarter - , subq_24.paid_at__year - , subq_24.paid_at__extract_year - , subq_24.paid_at__extract_quarter - , subq_24.paid_at__extract_month - , subq_24.paid_at__extract_day - , subq_24.paid_at__extract_dow - , subq_24.paid_at__extract_doy - , subq_24.booking__ds__day - , subq_24.booking__ds__week - , subq_24.booking__ds__month - , subq_24.booking__ds__quarter - , subq_24.booking__ds__year - , subq_24.booking__ds__extract_year - , subq_24.booking__ds__extract_quarter - , subq_24.booking__ds__extract_month - , subq_24.booking__ds__extract_day - , subq_24.booking__ds__extract_dow - , subq_24.booking__ds__extract_doy - , subq_24.booking__ds_partitioned__day - , subq_24.booking__ds_partitioned__week - , subq_24.booking__ds_partitioned__month - , subq_24.booking__ds_partitioned__quarter - , subq_24.booking__ds_partitioned__year - , subq_24.booking__ds_partitioned__extract_year - , subq_24.booking__ds_partitioned__extract_quarter - , subq_24.booking__ds_partitioned__extract_month - , subq_24.booking__ds_partitioned__extract_day - , subq_24.booking__ds_partitioned__extract_dow - , subq_24.booking__ds_partitioned__extract_doy - , subq_24.booking__paid_at__day - , subq_24.booking__paid_at__week - , subq_24.booking__paid_at__month - , subq_24.booking__paid_at__quarter - , subq_24.booking__paid_at__year - , subq_24.booking__paid_at__extract_year - , subq_24.booking__paid_at__extract_quarter - , subq_24.booking__paid_at__extract_month - , subq_24.booking__paid_at__extract_day - , subq_24.booking__paid_at__extract_dow - , subq_24.booking__paid_at__extract_doy - , subq_24.ds__day AS metric_time__day - , subq_24.ds__week AS metric_time__week - , subq_24.ds__month AS metric_time__month - , subq_24.ds__quarter AS metric_time__quarter - , subq_24.ds__year AS metric_time__year - , subq_24.ds__extract_year AS metric_time__extract_year - , subq_24.ds__extract_quarter AS metric_time__extract_quarter - , subq_24.ds__extract_month AS metric_time__extract_month - , subq_24.ds__extract_day AS metric_time__extract_day - , subq_24.ds__extract_dow AS metric_time__extract_dow - , subq_24.ds__extract_doy AS metric_time__extract_doy - , subq_24.listing - , subq_24.guest - , subq_24.host - , subq_24.booking__listing - , subq_24.booking__guest - , subq_24.booking__host - , subq_24.is_instant - , subq_24.booking__is_instant - , subq_24.bookings - , subq_24.instant_bookings - , subq_24.booking_value - , subq_24.max_booking_value - , subq_24.min_booking_value - , subq_24.bookers - , subq_24.average_booking_value - , subq_24.referred_bookings - , subq_24.median_booking_value - , subq_24.booking_value_p99 - , subq_24.discrete_booking_value_p99 - , subq_24.approximate_continuous_booking_value_p99 - , subq_24.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.ds__day AS metric_time__day + , subq_33.ds__week AS metric_time__week + , subq_33.ds__month AS metric_time__month + , subq_33.ds__quarter AS metric_time__quarter + , subq_33.ds__year AS metric_time__year + , subq_33.ds__extract_year AS metric_time__extract_year + , subq_33.ds__extract_quarter AS metric_time__extract_quarter + , subq_33.ds__extract_month AS metric_time__extract_month + , subq_33.ds__extract_day AS metric_time__extract_day + , subq_33.ds__extract_dow AS metric_time__extract_dow + , subq_33.ds__extract_doy AS 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 ( -- 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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_24 - ) subq_25 - ) subq_26 + , 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_33 + ) subq_34 + ) subq_35 GROUP BY - subq_26.metric_time__day - ) subq_27 - ) subq_28 + subq_35.metric_time__day + ) subq_36 + ) subq_37 ON - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day) = subq_37.metric_time__day GROUP BY - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) -) subq_29 + COALESCE(subq_20.metric_time__day, subq_32.metric_time__day, subq_37.metric_time__day) +) subq_38 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0_optimized.sql index 69ba3892a2..91ab825138 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0_optimized.sql @@ -5,10 +5,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) AS metric_time__day - , MAX(subq_41.average_booking_value) AS average_booking_value - , MAX(subq_53.bookings) AS bookings - , MAX(subq_58.booking_value) AS booking_value + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day, subq_67.metric_time__day) AS metric_time__day + , MAX(subq_50.average_booking_value) AS average_booking_value + , MAX(subq_62.bookings) AS bookings + , MAX(subq_67.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -21,19 +21,19 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - DATE_TRUNC('day', bookings_source_src_28001.ds) AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , bookings_source_src_28001.booking_value AS average_booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + DATE_TRUNC('day', bookings_source_src_28000.ds) AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , bookings_source_src_28000.booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - bookings_source_src_28001.listing_id = listings_latest_src_28005.listing_id - ) subq_37 + bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id + ) subq_46 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_41 + ) subq_50 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -46,9 +46,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_44.metric_time__day AS metric_time__day - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , subq_44.bookings AS bookings + subq_53.metric_time__day AS metric_time__day + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_53.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -57,19 +57,19 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_44 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_53 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28005 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_44.listing = listings_latest_src_28005.listing_id - ) subq_49 + subq_53.listing = listings_latest_src_28000.listing_id + ) subq_58 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_53 + ) subq_62 ON - subq_41.metric_time__day = subq_53.metric_time__day + subq_50.metric_time__day = subq_62.metric_time__day FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -79,12 +79,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_58 + ) subq_67 ON - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day) = subq_58.metric_time__day + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day) = subq_67.metric_time__day GROUP BY - COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) -) subq_59 + COALESCE(subq_50.metric_time__day, subq_62.metric_time__day, subq_67.metric_time__day) +) subq_68 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0.sql index 9c036af743..d2b83fe074 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,460 +1,460 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , CAST(subq_12.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_12.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio + subq_21.metric_time__day + , CAST(subq_21.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_21.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , MAX(subq_6.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_11.booking_value) AS booking_value + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day + , MAX(subq_15.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_20.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.booking_value AS booking_value_with_is_instant_constraint + subq_14.metric_time__day + , subq_14.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.booking_value) AS booking_value + subq_13.metric_time__day + , SUM(subq_13.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.booking_value + subq_12.metric_time__day + , subq_12.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.booking_value + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.booking_value + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.booking_value 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_13.metric_time__day + ) subq_14 + ) subq_15 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_19.metric_time__day + , subq_19.booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.booking_value) AS booking_value + subq_18.metric_time__day + , SUM(subq_18.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking_value + subq_17.metric_time__day + , subq_17.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_16.ds__day + , subq_16.ds__week + , subq_16.ds__month + , subq_16.ds__quarter + , subq_16.ds__year + , subq_16.ds__extract_year + , subq_16.ds__extract_quarter + , subq_16.ds__extract_month + , subq_16.ds__extract_day + , subq_16.ds__extract_dow + , subq_16.ds__extract_doy + , subq_16.ds_partitioned__day + , subq_16.ds_partitioned__week + , subq_16.ds_partitioned__month + , subq_16.ds_partitioned__quarter + , subq_16.ds_partitioned__year + , subq_16.ds_partitioned__extract_year + , subq_16.ds_partitioned__extract_quarter + , subq_16.ds_partitioned__extract_month + , subq_16.ds_partitioned__extract_day + , subq_16.ds_partitioned__extract_dow + , subq_16.ds_partitioned__extract_doy + , subq_16.paid_at__day + , subq_16.paid_at__week + , subq_16.paid_at__month + , subq_16.paid_at__quarter + , subq_16.paid_at__year + , subq_16.paid_at__extract_year + , subq_16.paid_at__extract_quarter + , subq_16.paid_at__extract_month + , subq_16.paid_at__extract_day + , subq_16.paid_at__extract_dow + , subq_16.paid_at__extract_doy + , subq_16.booking__ds__day + , subq_16.booking__ds__week + , subq_16.booking__ds__month + , subq_16.booking__ds__quarter + , subq_16.booking__ds__year + , subq_16.booking__ds__extract_year + , subq_16.booking__ds__extract_quarter + , subq_16.booking__ds__extract_month + , subq_16.booking__ds__extract_day + , subq_16.booking__ds__extract_dow + , subq_16.booking__ds__extract_doy + , subq_16.booking__ds_partitioned__day + , subq_16.booking__ds_partitioned__week + , subq_16.booking__ds_partitioned__month + , subq_16.booking__ds_partitioned__quarter + , subq_16.booking__ds_partitioned__year + , subq_16.booking__ds_partitioned__extract_year + , subq_16.booking__ds_partitioned__extract_quarter + , subq_16.booking__ds_partitioned__extract_month + , subq_16.booking__ds_partitioned__extract_day + , subq_16.booking__ds_partitioned__extract_dow + , subq_16.booking__ds_partitioned__extract_doy + , subq_16.booking__paid_at__day + , subq_16.booking__paid_at__week + , subq_16.booking__paid_at__month + , subq_16.booking__paid_at__quarter + , subq_16.booking__paid_at__year + , subq_16.booking__paid_at__extract_year + , subq_16.booking__paid_at__extract_quarter + , subq_16.booking__paid_at__extract_month + , subq_16.booking__paid_at__extract_day + , subq_16.booking__paid_at__extract_dow + , subq_16.booking__paid_at__extract_doy + , subq_16.ds__day AS metric_time__day + , subq_16.ds__week AS metric_time__week + , subq_16.ds__month AS metric_time__month + , subq_16.ds__quarter AS metric_time__quarter + , subq_16.ds__year AS metric_time__year + , subq_16.ds__extract_year AS metric_time__extract_year + , subq_16.ds__extract_quarter AS metric_time__extract_quarter + , subq_16.ds__extract_month AS metric_time__extract_month + , subq_16.ds__extract_day AS metric_time__extract_day + , subq_16.ds__extract_dow AS metric_time__extract_dow + , subq_16.ds__extract_doy AS metric_time__extract_doy + , subq_16.listing + , subq_16.guest + , subq_16.host + , subq_16.booking__listing + , subq_16.booking__guest + , subq_16.booking__host + , subq_16.is_instant + , subq_16.booking__is_instant + , subq_16.bookings + , subq_16.instant_bookings + , subq_16.booking_value + , subq_16.max_booking_value + , subq_16.min_booking_value + , subq_16.bookers + , subq_16.average_booking_value + , subq_16.referred_bookings + , subq_16.median_booking_value + , subq_16.booking_value_p99 + , subq_16.discrete_booking_value_p99 + , subq_16.approximate_continuous_booking_value_p99 + , subq_16.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_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_7 - ) subq_8 - ) subq_9 + , 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_16 + ) subq_17 + ) subq_18 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_18.metric_time__day + ) subq_19 + ) subq_20 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_15.metric_time__day = subq_20.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) +) subq_21 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0_optimized.sql index d384201243..e6c18549b2 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/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_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , MAX(subq_19.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_24.booking_value) AS booking_value + COALESCE(subq_28.metric_time__day, subq_33.metric_time__day) AS metric_time__day + , MAX(subq_28.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_33.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -24,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_24 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_28 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -39,12 +39,12 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_33 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_28.metric_time__day = subq_33.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_28.metric_time__day, subq_33.metric_time__day) +) subq_34 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0.sql index da0a36e00e..26959b81c1 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,234 +1,234 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day + subq_15.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.bookings AS delayed_bookings + subq_14.metric_time__day + , subq_14.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_13.metric_time__day + , SUM(subq_13.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_12.metric_time__day + , subq_12.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_11.metric_time__day + , subq_11.booking__is_instant + , subq_11.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_10.metric_time__day + , subq_10.booking__is_instant + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 WHERE NOT booking__is_instant - ) subq_3 - ) subq_4 + ) subq_12 + ) subq_13 GROUP BY - subq_4.metric_time__day - ) subq_5 -) subq_6 + subq_13.metric_time__day + ) subq_14 +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index df414b0013..c494772d25 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -18,9 +18,9 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_13 +) subq_22 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 7de9dc9aee..d68482dfe1 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -1,366 +1,366 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_10.bookings AS DOUBLE) / CAST(NULLIF(subq_10.listings, 0) AS DOUBLE) AS bookings_per_listing + CAST(subq_19.bookings AS DOUBLE) / CAST(NULLIF(subq_19.listings, 0) AS DOUBLE) AS bookings_per_listing FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_4.bookings) AS bookings - , MAX(subq_9.listings) AS listings + MAX(subq_13.bookings) AS bookings + , MAX(subq_18.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_3.bookings + subq_12.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_2.bookings) AS bookings + SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_1.bookings + subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 - ) subq_3 - ) subq_4 + , 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_9 + ) subq_10 + ) subq_11 + ) subq_12 + ) subq_13 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_8.listings + subq_17.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_7.listings) AS listings + SUM(subq_16.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_6.listings + subq_15.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.created_at__day - , subq_5.created_at__week - , subq_5.created_at__month - , subq_5.created_at__quarter - , subq_5.created_at__year - , subq_5.created_at__extract_year - , subq_5.created_at__extract_quarter - , subq_5.created_at__extract_month - , subq_5.created_at__extract_day - , subq_5.created_at__extract_dow - , subq_5.created_at__extract_doy - , subq_5.listing__ds__day - , subq_5.listing__ds__week - , subq_5.listing__ds__month - , subq_5.listing__ds__quarter - , subq_5.listing__ds__year - , subq_5.listing__ds__extract_year - , subq_5.listing__ds__extract_quarter - , subq_5.listing__ds__extract_month - , subq_5.listing__ds__extract_day - , subq_5.listing__ds__extract_dow - , subq_5.listing__ds__extract_doy - , subq_5.listing__created_at__day - , subq_5.listing__created_at__week - , subq_5.listing__created_at__month - , subq_5.listing__created_at__quarter - , subq_5.listing__created_at__year - , subq_5.listing__created_at__extract_year - , subq_5.listing__created_at__extract_quarter - , subq_5.listing__created_at__extract_month - , subq_5.listing__created_at__extract_day - , subq_5.listing__created_at__extract_dow - , subq_5.listing__created_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.user - , subq_5.listing__user - , subq_5.country_latest - , subq_5.is_lux_latest - , subq_5.capacity_latest - , subq_5.listing__country_latest - , subq_5.listing__is_lux_latest - , subq_5.listing__capacity_latest - , subq_5.listings - , subq_5.largest_listing - , subq_5.smallest_listing + 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.created_at__day + , subq_14.created_at__week + , subq_14.created_at__month + , subq_14.created_at__quarter + , subq_14.created_at__year + , subq_14.created_at__extract_year + , subq_14.created_at__extract_quarter + , subq_14.created_at__extract_month + , subq_14.created_at__extract_day + , subq_14.created_at__extract_dow + , subq_14.created_at__extract_doy + , subq_14.listing__ds__day + , subq_14.listing__ds__week + , subq_14.listing__ds__month + , subq_14.listing__ds__quarter + , subq_14.listing__ds__year + , subq_14.listing__ds__extract_year + , subq_14.listing__ds__extract_quarter + , subq_14.listing__ds__extract_month + , subq_14.listing__ds__extract_day + , subq_14.listing__ds__extract_dow + , subq_14.listing__ds__extract_doy + , subq_14.listing__created_at__day + , subq_14.listing__created_at__week + , subq_14.listing__created_at__month + , subq_14.listing__created_at__quarter + , subq_14.listing__created_at__year + , subq_14.listing__created_at__extract_year + , subq_14.listing__created_at__extract_quarter + , subq_14.listing__created_at__extract_month + , subq_14.listing__created_at__extract_day + , subq_14.listing__created_at__extract_dow + , subq_14.listing__created_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.user + , subq_14.listing__user + , subq_14.country_latest + , subq_14.is_lux_latest + , subq_14.capacity_latest + , subq_14.listing__country_latest + , subq_14.listing__is_lux_latest + , subq_14.listing__capacity_latest + , subq_14.listings + , subq_14.largest_listing + , subq_14.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_5 - ) subq_6 - ) subq_7 - ) subq_8 - ) subq_9 -) subq_10 + , 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_14 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index 13f8ff2353..c293244ecc 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_15.bookings) AS DOUBLE) / CAST(NULLIF(MAX(subq_20.listings), 0) AS DOUBLE) AS bookings_per_listing + CAST(MAX(subq_24.bookings) AS DOUBLE) / CAST(NULLIF(MAX(subq_29.listings), 0) AS DOUBLE) AS bookings_per_listing FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -10,8 +10,8 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 -) subq_15 + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_24 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -20,5 +20,5 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 -) subq_20 + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_29 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_categorical__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_categorical__plan0.sql index f13704b88c..6c9fa9074c 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_categorical__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_categorical__plan0.sql @@ -10,62 +10,62 @@ FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 + , 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 GROUP BY subq_0.listing__country_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_categorical__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_categorical__plan0_optimized.sql index c1da0c0382..a8d1afa6a8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_categorical__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_categorical__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 GROUP BY country ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time__plan0.sql index 888670ea3b..56908c76e2 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY subq_0.booking__paid_at__day diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time__plan0_optimized.sql index 280b915894..e6a861c58f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__day',] SELECT DATE_TRUNC('day', paid_at) AS booking__paid_at__day - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', paid_at) ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time_quarter__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time_quarter__plan0.sql index 98be7043db..b957d25a10 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time_quarter__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time_quarter__plan0.sql @@ -11,93 +11,93 @@ FROM ( SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 + , 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 GROUP BY subq_0.booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time_quarter__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time_quarter__plan0_optimized.sql index f6d583edbe..5ff0fa4feb 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time_quarter__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_min_max_only_time_quarter__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: ['booking__paid_at__quarter',] SELECT DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('quarter', paid_at) ) subq_3 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0.sql index cf631e5e31..716f1773b8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__user__home_state_latest - , subq_10.bookings + subq_23.metric_time__day + , subq_23.listing__user__home_state_latest + , subq_23.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest - , SUM(subq_9.bookings) AS bookings + subq_22.metric_time__day + , subq_22.listing__user__home_state_latest + , SUM(subq_22.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__home_state_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__user__home_state_latest - , subq_8.bookings + subq_21.metric_time__day + , subq_21.listing__user__home_state_latest + , subq_21.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.window_start__day AS listing__window_start__day - , subq_7.window_end__day AS listing__window_end__day - , subq_2.listing AS listing - , subq_7.user__home_state_latest AS listing__user__home_state_latest - , subq_2.bookings AS bookings + subq_15.metric_time__day AS metric_time__day + , subq_20.window_start__day AS listing__window_start__day + , subq_20.window_end__day AS listing__window_end__day + , subq_15.listing AS listing + , subq_20.user__home_state_latest AS listing__user__home_state_latest + , subq_15.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_14.metric_time__day + , subq_14.listing + , subq_14.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.user + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.booking__user + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.bookers + , subq_13.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,142 +211,142 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_13 + ) subq_14 + ) subq_15 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_6.window_start__day - , subq_6.window_end__day - , subq_6.listing - , subq_6.user__home_state_latest + subq_19.window_start__day + , subq_19.window_end__day + , subq_19.listing + , subq_19.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_3.window_start__day AS window_start__day - , subq_3.window_start__week AS window_start__week - , subq_3.window_start__month AS window_start__month - , subq_3.window_start__quarter AS window_start__quarter - , subq_3.window_start__year AS window_start__year - , subq_3.window_start__extract_year AS window_start__extract_year - , subq_3.window_start__extract_quarter AS window_start__extract_quarter - , subq_3.window_start__extract_month AS window_start__extract_month - , subq_3.window_start__extract_day AS window_start__extract_day - , subq_3.window_start__extract_dow AS window_start__extract_dow - , subq_3.window_start__extract_doy AS window_start__extract_doy - , subq_3.window_end__day AS window_end__day - , subq_3.window_end__week AS window_end__week - , subq_3.window_end__month AS window_end__month - , subq_3.window_end__quarter AS window_end__quarter - , subq_3.window_end__year AS window_end__year - , subq_3.window_end__extract_year AS window_end__extract_year - , subq_3.window_end__extract_quarter AS window_end__extract_quarter - , subq_3.window_end__extract_month AS window_end__extract_month - , subq_3.window_end__extract_day AS window_end__extract_day - , subq_3.window_end__extract_dow AS window_end__extract_dow - , subq_3.window_end__extract_doy AS window_end__extract_doy - , subq_3.listing__window_start__day AS listing__window_start__day - , subq_3.listing__window_start__week AS listing__window_start__week - , subq_3.listing__window_start__month AS listing__window_start__month - , subq_3.listing__window_start__quarter AS listing__window_start__quarter - , subq_3.listing__window_start__year AS listing__window_start__year - , subq_3.listing__window_start__extract_year AS listing__window_start__extract_year - , subq_3.listing__window_start__extract_quarter AS listing__window_start__extract_quarter - , subq_3.listing__window_start__extract_month AS listing__window_start__extract_month - , subq_3.listing__window_start__extract_day AS listing__window_start__extract_day - , subq_3.listing__window_start__extract_dow AS listing__window_start__extract_dow - , subq_3.listing__window_start__extract_doy AS listing__window_start__extract_doy - , subq_3.listing__window_end__day AS listing__window_end__day - , subq_3.listing__window_end__week AS listing__window_end__week - , subq_3.listing__window_end__month AS listing__window_end__month - , subq_3.listing__window_end__quarter AS listing__window_end__quarter - , subq_3.listing__window_end__year AS listing__window_end__year - , subq_3.listing__window_end__extract_year AS listing__window_end__extract_year - , subq_3.listing__window_end__extract_quarter AS listing__window_end__extract_quarter - , subq_3.listing__window_end__extract_month AS listing__window_end__extract_month - , subq_3.listing__window_end__extract_day AS listing__window_end__extract_day - , subq_3.listing__window_end__extract_dow AS listing__window_end__extract_dow - , subq_3.listing__window_end__extract_doy AS listing__window_end__extract_doy - , subq_5.ds__day AS user__ds__day - , subq_5.ds__week AS user__ds__week - , subq_5.ds__month AS user__ds__month - , subq_5.ds__quarter AS user__ds__quarter - , subq_5.ds__year AS user__ds__year - , subq_5.ds__extract_year AS user__ds__extract_year - , subq_5.ds__extract_quarter AS user__ds__extract_quarter - , subq_5.ds__extract_month AS user__ds__extract_month - , subq_5.ds__extract_day AS user__ds__extract_day - , subq_5.ds__extract_dow AS user__ds__extract_dow - , subq_5.ds__extract_doy AS user__ds__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country AS country - , subq_3.is_lux AS is_lux - , subq_3.capacity AS capacity - , subq_3.listing__country AS listing__country - , subq_3.listing__is_lux AS listing__is_lux - , subq_3.listing__capacity AS listing__capacity - , subq_5.home_state_latest AS user__home_state_latest + subq_16.window_start__day AS window_start__day + , subq_16.window_start__week AS window_start__week + , subq_16.window_start__month AS window_start__month + , subq_16.window_start__quarter AS window_start__quarter + , subq_16.window_start__year AS window_start__year + , subq_16.window_start__extract_year AS window_start__extract_year + , subq_16.window_start__extract_quarter AS window_start__extract_quarter + , subq_16.window_start__extract_month AS window_start__extract_month + , subq_16.window_start__extract_day AS window_start__extract_day + , subq_16.window_start__extract_dow AS window_start__extract_dow + , subq_16.window_start__extract_doy AS window_start__extract_doy + , subq_16.window_end__day AS window_end__day + , subq_16.window_end__week AS window_end__week + , subq_16.window_end__month AS window_end__month + , subq_16.window_end__quarter AS window_end__quarter + , subq_16.window_end__year AS window_end__year + , subq_16.window_end__extract_year AS window_end__extract_year + , subq_16.window_end__extract_quarter AS window_end__extract_quarter + , subq_16.window_end__extract_month AS window_end__extract_month + , subq_16.window_end__extract_day AS window_end__extract_day + , subq_16.window_end__extract_dow AS window_end__extract_dow + , subq_16.window_end__extract_doy AS window_end__extract_doy + , subq_16.listing__window_start__day AS listing__window_start__day + , subq_16.listing__window_start__week AS listing__window_start__week + , subq_16.listing__window_start__month AS listing__window_start__month + , subq_16.listing__window_start__quarter AS listing__window_start__quarter + , subq_16.listing__window_start__year AS listing__window_start__year + , subq_16.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_16.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_16.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_16.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_16.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_16.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_16.listing__window_end__day AS listing__window_end__day + , subq_16.listing__window_end__week AS listing__window_end__week + , subq_16.listing__window_end__month AS listing__window_end__month + , subq_16.listing__window_end__quarter AS listing__window_end__quarter + , subq_16.listing__window_end__year AS listing__window_end__year + , subq_16.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_16.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_16.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_16.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_16.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_16.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_18.ds__day AS user__ds__day + , subq_18.ds__week AS user__ds__week + , subq_18.ds__month AS user__ds__month + , subq_18.ds__quarter AS user__ds__quarter + , subq_18.ds__year AS user__ds__year + , subq_18.ds__extract_year AS user__ds__extract_year + , subq_18.ds__extract_quarter AS user__ds__extract_quarter + , subq_18.ds__extract_month AS user__ds__extract_month + , subq_18.ds__extract_day AS user__ds__extract_day + , subq_18.ds__extract_dow AS user__ds__extract_dow + , subq_18.ds__extract_doy AS user__ds__extract_doy + , subq_16.listing AS listing + , subq_16.user AS user + , subq_16.listing__user AS listing__user + , subq_16.country AS country + , subq_16.is_lux AS is_lux + , subq_16.capacity AS capacity + , subq_16.listing__country AS listing__country + , subq_16.listing__is_lux AS listing__is_lux + , subq_16.listing__capacity AS listing__capacity + , subq_18.home_state_latest AS user__home_state_latest FROM ( -- Read Elements From Semantic Model 'listings' SELECT - listings_src_26002.active_from AS window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS window_start__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_src_26002.active_from) AS window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS window_start__extract_doy - , listings_src_26002.active_to AS window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS window_end__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_src_26002.active_to) AS window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS window_end__extract_doy - , listings_src_26002.country - , listings_src_26002.is_lux - , listings_src_26002.capacity - , listings_src_26002.active_from AS listing__window_start__day - , DATE_TRUNC('week', listings_src_26002.active_from) AS listing__window_start__week - , DATE_TRUNC('month', listings_src_26002.active_from) AS listing__window_start__month - , DATE_TRUNC('quarter', listings_src_26002.active_from) AS listing__window_start__quarter - , DATE_TRUNC('year', listings_src_26002.active_from) AS listing__window_start__year - , EXTRACT(year FROM listings_src_26002.active_from) AS listing__window_start__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_from) AS listing__window_start__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_from) AS listing__window_start__extract_month - , EXTRACT(day FROM listings_src_26002.active_from) AS listing__window_start__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_src_26002.active_from) AS listing__window_start__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_from) AS listing__window_start__extract_doy - , listings_src_26002.active_to AS listing__window_end__day - , DATE_TRUNC('week', listings_src_26002.active_to) AS listing__window_end__week - , DATE_TRUNC('month', listings_src_26002.active_to) AS listing__window_end__month - , DATE_TRUNC('quarter', listings_src_26002.active_to) AS listing__window_end__quarter - , DATE_TRUNC('year', listings_src_26002.active_to) AS listing__window_end__year - , EXTRACT(year FROM listings_src_26002.active_to) AS listing__window_end__extract_year - , EXTRACT(quarter FROM listings_src_26002.active_to) AS listing__window_end__extract_quarter - , EXTRACT(month FROM listings_src_26002.active_to) AS listing__window_end__extract_month - , EXTRACT(day FROM listings_src_26002.active_to) AS listing__window_end__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_src_26002.active_to) AS listing__window_end__extract_dow - , EXTRACT(doy FROM listings_src_26002.active_to) AS listing__window_end__extract_doy - , listings_src_26002.country AS listing__country - , listings_src_26002.is_lux AS listing__is_lux - , listings_src_26002.capacity AS listing__capacity - , listings_src_26002.listing_id AS listing - , listings_src_26002.user_id AS user - , listings_src_26002.user_id AS listing__user - FROM ***************************.dim_listings listings_src_26002 - ) subq_3 + listings_src_26000.active_from AS window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS window_start__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_src_26000.active_from) AS window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS window_start__extract_doy + , listings_src_26000.active_to AS window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS window_end__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_src_26000.active_to) AS window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS window_end__extract_doy + , listings_src_26000.country + , listings_src_26000.is_lux + , listings_src_26000.capacity + , listings_src_26000.active_from AS listing__window_start__day + , DATE_TRUNC('week', listings_src_26000.active_from) AS listing__window_start__week + , DATE_TRUNC('month', listings_src_26000.active_from) AS listing__window_start__month + , DATE_TRUNC('quarter', listings_src_26000.active_from) AS listing__window_start__quarter + , DATE_TRUNC('year', listings_src_26000.active_from) AS listing__window_start__year + , EXTRACT(year FROM listings_src_26000.active_from) AS listing__window_start__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_from) AS listing__window_start__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_from) AS listing__window_start__extract_month + , EXTRACT(day FROM listings_src_26000.active_from) AS listing__window_start__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_src_26000.active_from) AS listing__window_start__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_from) AS listing__window_start__extract_doy + , listings_src_26000.active_to AS listing__window_end__day + , DATE_TRUNC('week', listings_src_26000.active_to) AS listing__window_end__week + , DATE_TRUNC('month', listings_src_26000.active_to) AS listing__window_end__month + , DATE_TRUNC('quarter', listings_src_26000.active_to) AS listing__window_end__quarter + , DATE_TRUNC('year', listings_src_26000.active_to) AS listing__window_end__year + , EXTRACT(year FROM listings_src_26000.active_to) AS listing__window_end__extract_year + , EXTRACT(quarter FROM listings_src_26000.active_to) AS listing__window_end__extract_quarter + , EXTRACT(month FROM listings_src_26000.active_to) AS listing__window_end__extract_month + , EXTRACT(day FROM listings_src_26000.active_to) AS listing__window_end__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_src_26000.active_to) AS listing__window_end__extract_dow + , EXTRACT(doy FROM listings_src_26000.active_to) AS listing__window_end__extract_doy + , listings_src_26000.country AS listing__country + , listings_src_26000.is_lux AS listing__is_lux + , listings_src_26000.capacity AS listing__capacity + , listings_src_26000.listing_id AS listing + , listings_src_26000.user_id AS user + , listings_src_26000.user_id AS listing__user + FROM ***************************.dim_listings listings_src_26000 + ) subq_16 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,83 +376,83 @@ FROM ( -- 'user', -- ] SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.user__ds__day - , subq_4.user__ds__week - , subq_4.user__ds__month - , subq_4.user__ds__quarter - , subq_4.user__ds__year - , subq_4.user__ds__extract_year - , subq_4.user__ds__extract_quarter - , subq_4.user__ds__extract_month - , subq_4.user__ds__extract_day - , subq_4.user__ds__extract_dow - , subq_4.user__ds__extract_doy - , subq_4.user - , subq_4.home_state_latest - , subq_4.user__home_state_latest + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.user__ds__day + , subq_17.user__ds__week + , subq_17.user__ds__month + , subq_17.user__ds__quarter + , subq_17.user__ds__year + , subq_17.user__ds__extract_year + , subq_17.user__ds__extract_quarter + , subq_17.user__ds__extract_month + , subq_17.user__ds__extract_day + , subq_17.user__ds__extract_dow + , subq_17.user__ds__extract_doy + , subq_17.user + , subq_17.home_state_latest + , subq_17.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - DATE_TRUNC('day', users_latest_src_26006.ds) AS ds__day - , DATE_TRUNC('week', users_latest_src_26006.ds) AS ds__week - , DATE_TRUNC('month', users_latest_src_26006.ds) AS ds__month - , DATE_TRUNC('quarter', users_latest_src_26006.ds) AS ds__quarter - , DATE_TRUNC('year', users_latest_src_26006.ds) AS ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_26006.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_latest_src_26006.ds) AS ds__extract_doy - , users_latest_src_26006.home_state_latest - , DATE_TRUNC('day', users_latest_src_26006.ds) AS user__ds__day - , DATE_TRUNC('week', users_latest_src_26006.ds) AS user__ds__week - , DATE_TRUNC('month', users_latest_src_26006.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_latest_src_26006.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_latest_src_26006.ds) AS user__ds__year - , EXTRACT(year FROM users_latest_src_26006.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_latest_src_26006.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_latest_src_26006.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_latest_src_26006.ds) AS user__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_26006.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_latest_src_26006.ds) AS user__ds__extract_doy - , users_latest_src_26006.home_state_latest AS user__home_state_latest - , users_latest_src_26006.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_26006 - ) subq_4 - ) subq_5 + DATE_TRUNC('day', users_latest_src_26000.ds) AS ds__day + , DATE_TRUNC('week', users_latest_src_26000.ds) AS ds__week + , DATE_TRUNC('month', users_latest_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', users_latest_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', users_latest_src_26000.ds) AS ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_latest_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_latest_src_26000.ds) AS ds__extract_doy + , users_latest_src_26000.home_state_latest + , DATE_TRUNC('day', users_latest_src_26000.ds) AS user__ds__day + , DATE_TRUNC('week', users_latest_src_26000.ds) AS user__ds__week + , DATE_TRUNC('month', users_latest_src_26000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_latest_src_26000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_latest_src_26000.ds) AS user__ds__year + , EXTRACT(year FROM users_latest_src_26000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_latest_src_26000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_latest_src_26000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_latest_src_26000.ds) AS user__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_latest_src_26000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_latest_src_26000.ds) AS user__ds__extract_doy + , users_latest_src_26000.home_state_latest AS user__home_state_latest + , users_latest_src_26000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_26000 + ) subq_17 + ) subq_18 ON - subq_3.user = subq_5.user - ) subq_6 - ) subq_7 + subq_16.user = subq_18.user + ) subq_19 + ) subq_20 ON ( - subq_2.listing = subq_7.listing + subq_15.listing = subq_20.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.window_start__day + subq_15.metric_time__day >= subq_20.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.window_end__day + subq_15.metric_time__day < subq_20.window_end__day ) OR ( - subq_7.window_end__day IS NULL + subq_20.window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_21 + ) subq_22 GROUP BY - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest -) subq_10 + subq_22.metric_time__day + , subq_22.listing__user__home_state_latest +) subq_23 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 1d7e6c24a7..f38afda4f7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.user__home_state_latest AS listing__user__home_state_latest - , SUM(subq_13.bookings) AS bookings + subq_26.metric_time__day AS metric_time__day + , subq_31.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_26.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,35 +15,35 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_26 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - listings_src_26002.active_from AS window_start__day - , listings_src_26002.active_to AS window_end__day - , listings_src_26002.listing_id AS listing - , users_latest_src_26006.home_state_latest AS user__home_state_latest - FROM ***************************.dim_listings listings_src_26002 + listings_src_26000.active_from AS window_start__day + , listings_src_26000.active_to AS window_end__day + , listings_src_26000.listing_id AS listing + , users_latest_src_26000.home_state_latest AS user__home_state_latest + FROM ***************************.dim_listings listings_src_26000 LEFT OUTER JOIN - ***************************.dim_users_latest users_latest_src_26006 + ***************************.dim_users_latest users_latest_src_26000 ON - listings_src_26002.user_id = users_latest_src_26006.user_id -) subq_18 + listings_src_26000.user_id = users_latest_src_26000.user_id +) subq_31 ON ( - subq_13.listing = subq_18.listing + subq_26.listing = subq_31.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_26.metric_time__day >= subq_31.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_26.metric_time__day < subq_31.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_31.window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.user__home_state_latest + subq_26.metric_time__day + , subq_31.user__home_state_latest diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0.sql index 38f654bc9d..1bcf204702 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__lux_listing__is_confirmed_lux - , subq_10.bookings + subq_15.metric_time__day + , subq_15.listing__lux_listing__is_confirmed_lux + , subq_15.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux - , SUM(subq_9.bookings) AS bookings + subq_14.metric_time__day + , subq_14.listing__lux_listing__is_confirmed_lux + , SUM(subq_14.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__lux_listing__is_confirmed_lux', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__lux_listing__is_confirmed_lux - , subq_8.bookings + subq_13.metric_time__day + , subq_13.listing__lux_listing__is_confirmed_lux + , subq_13.bookings FROM ( -- Join Standard Outputs SELECT - subq_2.metric_time__day AS metric_time__day - , subq_7.lux_listing__window_start__day AS listing__lux_listing__window_start__day - , subq_7.lux_listing__window_end__day AS listing__lux_listing__window_end__day - , subq_2.listing AS listing - , subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , subq_2.bookings AS bookings + subq_7.metric_time__day AS metric_time__day + , subq_12.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_12.lux_listing__window_end__day AS listing__lux_listing__window_end__day + , subq_7.listing AS listing + , subq_12.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_7.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_6.metric_time__day + , subq_6.listing + , subq_6.bookings 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.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.ds__day AS metric_time__day + , subq_5.ds__week AS metric_time__week + , subq_5.ds__month AS metric_time__month + , subq_5.ds__quarter AS metric_time__quarter + , subq_5.ds__year AS metric_time__year + , subq_5.ds__extract_year AS metric_time__extract_year + , subq_5.ds__extract_quarter AS metric_time__extract_quarter + , subq_5.ds__extract_month AS metric_time__extract_month + , subq_5.ds__extract_day AS metric_time__extract_day + , subq_5.ds__extract_dow AS metric_time__extract_dow + , subq_5.ds__extract_doy AS metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.user + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.booking__user + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.bookings + , subq_5.instant_bookings + , subq_5.booking_value + , subq_5.bookers + , subq_5.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,53 +211,53 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_5 + ) subq_6 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - subq_6.lux_listing__window_start__day - , subq_6.lux_listing__window_end__day - , subq_6.listing - , subq_6.lux_listing__is_confirmed_lux + subq_11.lux_listing__window_start__day + , subq_11.lux_listing__window_end__day + , subq_11.listing + , subq_11.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_5.window_start__day AS lux_listing__window_start__day - , subq_5.window_start__week AS lux_listing__window_start__week - , subq_5.window_start__month AS lux_listing__window_start__month - , subq_5.window_start__quarter AS lux_listing__window_start__quarter - , subq_5.window_start__year AS lux_listing__window_start__year - , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_5.window_end__day AS lux_listing__window_end__day - , subq_5.window_end__week AS lux_listing__window_end__week - , subq_5.window_end__month AS lux_listing__window_end__month - , subq_5.window_end__quarter AS lux_listing__window_end__quarter - , subq_5.window_end__year AS lux_listing__window_end__year - , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_3.listing AS listing - , subq_3.lux_listing AS lux_listing - , subq_3.listing__lux_listing AS listing__lux_listing - , subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux + subq_10.window_start__day AS lux_listing__window_start__day + , subq_10.window_start__week AS lux_listing__window_start__week + , subq_10.window_start__month AS lux_listing__window_start__month + , subq_10.window_start__quarter AS lux_listing__window_start__quarter + , subq_10.window_start__year AS lux_listing__window_start__year + , subq_10.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_10.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_10.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_10.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_10.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_10.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_10.window_end__day AS lux_listing__window_end__day + , subq_10.window_end__week AS lux_listing__window_end__week + , subq_10.window_end__month AS lux_listing__window_end__month + , subq_10.window_end__quarter AS lux_listing__window_end__quarter + , subq_10.window_end__year AS lux_listing__window_end__year + , subq_10.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_10.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_10.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_10.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_10.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_10.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_8.listing AS listing + , subq_8.lux_listing AS lux_listing + , subq_8.listing__lux_listing AS listing__lux_listing + , subq_10.is_confirmed_lux AS lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT - lux_listing_mapping_src_26003.listing_id AS listing - , lux_listing_mapping_src_26003.lux_listing_id AS lux_listing - , lux_listing_mapping_src_26003.lux_listing_id AS listing__lux_listing - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 - ) subq_3 + lux_listing_mapping_src_26000.listing_id AS listing + , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing + , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 + ) subq_8 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,127 +309,127 @@ FROM ( -- 'lux_listing', -- ] SELECT - subq_4.window_start__day - , subq_4.window_start__week - , subq_4.window_start__month - , subq_4.window_start__quarter - , subq_4.window_start__year - , subq_4.window_start__extract_year - , subq_4.window_start__extract_quarter - , subq_4.window_start__extract_month - , subq_4.window_start__extract_day - , subq_4.window_start__extract_dow - , subq_4.window_start__extract_doy - , subq_4.window_end__day - , subq_4.window_end__week - , subq_4.window_end__month - , subq_4.window_end__quarter - , subq_4.window_end__year - , subq_4.window_end__extract_year - , subq_4.window_end__extract_quarter - , subq_4.window_end__extract_month - , subq_4.window_end__extract_day - , subq_4.window_end__extract_dow - , subq_4.window_end__extract_doy - , subq_4.lux_listing__window_start__day - , subq_4.lux_listing__window_start__week - , subq_4.lux_listing__window_start__month - , subq_4.lux_listing__window_start__quarter - , subq_4.lux_listing__window_start__year - , subq_4.lux_listing__window_start__extract_year - , subq_4.lux_listing__window_start__extract_quarter - , subq_4.lux_listing__window_start__extract_month - , subq_4.lux_listing__window_start__extract_day - , subq_4.lux_listing__window_start__extract_dow - , subq_4.lux_listing__window_start__extract_doy - , subq_4.lux_listing__window_end__day - , subq_4.lux_listing__window_end__week - , subq_4.lux_listing__window_end__month - , subq_4.lux_listing__window_end__quarter - , subq_4.lux_listing__window_end__year - , subq_4.lux_listing__window_end__extract_year - , subq_4.lux_listing__window_end__extract_quarter - , subq_4.lux_listing__window_end__extract_month - , subq_4.lux_listing__window_end__extract_day - , subq_4.lux_listing__window_end__extract_dow - , subq_4.lux_listing__window_end__extract_doy - , subq_4.lux_listing - , subq_4.is_confirmed_lux - , subq_4.lux_listing__is_confirmed_lux + subq_9.window_start__day + , subq_9.window_start__week + , subq_9.window_start__month + , subq_9.window_start__quarter + , subq_9.window_start__year + , subq_9.window_start__extract_year + , subq_9.window_start__extract_quarter + , subq_9.window_start__extract_month + , subq_9.window_start__extract_day + , subq_9.window_start__extract_dow + , subq_9.window_start__extract_doy + , subq_9.window_end__day + , subq_9.window_end__week + , subq_9.window_end__month + , subq_9.window_end__quarter + , subq_9.window_end__year + , subq_9.window_end__extract_year + , subq_9.window_end__extract_quarter + , subq_9.window_end__extract_month + , subq_9.window_end__extract_day + , subq_9.window_end__extract_dow + , subq_9.window_end__extract_doy + , subq_9.lux_listing__window_start__day + , subq_9.lux_listing__window_start__week + , subq_9.lux_listing__window_start__month + , subq_9.lux_listing__window_start__quarter + , subq_9.lux_listing__window_start__year + , subq_9.lux_listing__window_start__extract_year + , subq_9.lux_listing__window_start__extract_quarter + , subq_9.lux_listing__window_start__extract_month + , subq_9.lux_listing__window_start__extract_day + , subq_9.lux_listing__window_start__extract_dow + , subq_9.lux_listing__window_start__extract_doy + , subq_9.lux_listing__window_end__day + , subq_9.lux_listing__window_end__week + , subq_9.lux_listing__window_end__month + , subq_9.lux_listing__window_end__quarter + , subq_9.lux_listing__window_end__year + , subq_9.lux_listing__window_end__extract_year + , subq_9.lux_listing__window_end__extract_quarter + , subq_9.lux_listing__window_end__extract_month + , subq_9.lux_listing__window_end__extract_day + , subq_9.lux_listing__window_end__extract_dow + , subq_9.lux_listing__window_end__extract_doy + , subq_9.lux_listing + , subq_9.is_confirmed_lux + , subq_9.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT - lux_listings_src_26004.valid_from AS window_start__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_from) AS window_start__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_from) AS window_start__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_from) AS window_start__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_from) AS window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS window_start__extract_day - , EXTRACT(DAY_OF_WEEK FROM lux_listings_src_26004.valid_from) AS window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_from) AS window_start__extract_doy - , lux_listings_src_26004.valid_to AS window_end__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_to) AS window_end__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_to) AS window_end__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_to) AS window_end__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_to) AS window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS window_end__extract_day - , EXTRACT(DAY_OF_WEEK FROM lux_listings_src_26004.valid_to) AS window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_to) AS window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux - , lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_from) AS lux_listing__window_start__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_from) AS lux_listing__window_start__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_from) AS lux_listing__window_start__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_from) AS lux_listing__window_start__year - , EXTRACT(year FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_day - , EXTRACT(DAY_OF_WEEK FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_from) AS lux_listing__window_start__extract_doy - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , DATE_TRUNC('week', lux_listings_src_26004.valid_to) AS lux_listing__window_end__week - , DATE_TRUNC('month', lux_listings_src_26004.valid_to) AS lux_listing__window_end__month - , DATE_TRUNC('quarter', lux_listings_src_26004.valid_to) AS lux_listing__window_end__quarter - , DATE_TRUNC('year', lux_listings_src_26004.valid_to) AS lux_listing__window_end__year - , EXTRACT(year FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_year - , EXTRACT(quarter FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_quarter - , EXTRACT(month FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_month - , EXTRACT(day FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_day - , EXTRACT(DAY_OF_WEEK FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_dow - , EXTRACT(doy FROM lux_listings_src_26004.valid_to) AS lux_listing__window_end__extract_doy - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - , lux_listings_src_26004.lux_listing_id AS lux_listing - FROM ***************************.dim_lux_listings lux_listings_src_26004 - ) subq_4 - ) subq_5 + lux_listings_src_26000.valid_from AS window_start__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_from) AS window_start__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_from) AS window_start__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_from) AS window_start__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_from) AS window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS window_start__extract_day + , EXTRACT(DAY_OF_WEEK FROM lux_listings_src_26000.valid_from) AS window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_from) AS window_start__extract_doy + , lux_listings_src_26000.valid_to AS window_end__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_to) AS window_end__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_to) AS window_end__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_to) AS window_end__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_to) AS window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS window_end__extract_day + , EXTRACT(DAY_OF_WEEK FROM lux_listings_src_26000.valid_to) AS window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_to) AS window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux + , lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_from) AS lux_listing__window_start__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_from) AS lux_listing__window_start__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_from) AS lux_listing__window_start__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_from) AS lux_listing__window_start__year + , EXTRACT(year FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_day + , EXTRACT(DAY_OF_WEEK FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_from) AS lux_listing__window_start__extract_doy + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , DATE_TRUNC('week', lux_listings_src_26000.valid_to) AS lux_listing__window_end__week + , DATE_TRUNC('month', lux_listings_src_26000.valid_to) AS lux_listing__window_end__month + , DATE_TRUNC('quarter', lux_listings_src_26000.valid_to) AS lux_listing__window_end__quarter + , DATE_TRUNC('year', lux_listings_src_26000.valid_to) AS lux_listing__window_end__year + , EXTRACT(year FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_year + , EXTRACT(quarter FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_quarter + , EXTRACT(month FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_month + , EXTRACT(day FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_day + , EXTRACT(DAY_OF_WEEK FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_dow + , EXTRACT(doy FROM lux_listings_src_26000.valid_to) AS lux_listing__window_end__extract_doy + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + , lux_listings_src_26000.lux_listing_id AS lux_listing + FROM ***************************.dim_lux_listings lux_listings_src_26000 + ) subq_9 + ) subq_10 ON - subq_3.lux_listing = subq_5.lux_listing - ) subq_6 - ) subq_7 + subq_8.lux_listing = subq_10.lux_listing + ) subq_11 + ) subq_12 ON ( - subq_2.listing = subq_7.listing + subq_7.listing = subq_12.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.lux_listing__window_start__day + subq_7.metric_time__day >= subq_12.lux_listing__window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.lux_listing__window_end__day + subq_7.metric_time__day < subq_12.lux_listing__window_end__day ) OR ( - subq_7.lux_listing__window_end__day IS NULL + subq_12.lux_listing__window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_13 + ) subq_14 GROUP BY - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux -) subq_10 + subq_14.metric_time__day + , subq_14.listing__lux_listing__is_confirmed_lux +) subq_15 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0_optimized.sql index 0ef5f08ffa..eb9b15d13c 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , SUM(subq_13.bookings) AS bookings + subq_18.metric_time__day AS metric_time__day + , subq_23.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_18.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,35 +15,35 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_18 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - lux_listings_src_26004.valid_from AS lux_listing__window_start__day - , lux_listings_src_26004.valid_to AS lux_listing__window_end__day - , lux_listing_mapping_src_26003.listing_id AS listing - , lux_listings_src_26004.is_confirmed_lux AS lux_listing__is_confirmed_lux - FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26003 + lux_listings_src_26000.valid_from AS lux_listing__window_start__day + , lux_listings_src_26000.valid_to AS lux_listing__window_end__day + , lux_listing_mapping_src_26000.listing_id AS listing + , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux + FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 LEFT OUTER JOIN - ***************************.dim_lux_listings lux_listings_src_26004 + ***************************.dim_lux_listings lux_listings_src_26000 ON - lux_listing_mapping_src_26003.lux_listing_id = lux_listings_src_26004.lux_listing_id -) subq_18 + lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id +) subq_23 ON ( - subq_13.listing = subq_18.listing + subq_18.listing = subq_23.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.lux_listing__window_start__day + subq_18.metric_time__day >= subq_23.lux_listing__window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.lux_listing__window_end__day + subq_18.metric_time__day < subq_23.lux_listing__window_end__day ) OR ( - subq_18.lux_listing__window_end__day IS NULL + subq_23.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.lux_listing__is_confirmed_lux + subq_18.metric_time__day + , subq_23.lux_listing__is_confirmed_lux diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0.sql index a10cff334a..1f2427be6f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0.sql @@ -1,93 +1,93 @@ -- Compute Metrics via Expressions SELECT - subq_10.account_id__customer_id__customer_name - , subq_10.txn_count + subq_14.account_id__customer_id__customer_name + , subq_14.txn_count FROM ( -- Aggregate Measures SELECT - subq_9.account_id__customer_id__customer_name - , SUM(subq_9.txn_count) AS txn_count + subq_13.account_id__customer_id__customer_name + , SUM(subq_13.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_8.account_id__customer_id__customer_name - , subq_8.txn_count + subq_12.account_id__customer_id__customer_name + , subq_12.txn_count FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_2.account_id AS account_id - , subq_7.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_2.txn_count AS txn_count + subq_6.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_6.account_id AS account_id + , subq_11.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_6.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_1.ds_partitioned__day - , subq_1.account_id - , subq_1.txn_count + subq_5.ds_partitioned__day + , subq_5.account_id + , subq_5.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.account_id__ds_partitioned__day - , subq_0.account_id__ds_partitioned__week - , subq_0.account_id__ds_partitioned__month - , subq_0.account_id__ds_partitioned__quarter - , subq_0.account_id__ds_partitioned__year - , subq_0.account_id__ds_partitioned__extract_year - , subq_0.account_id__ds_partitioned__extract_quarter - , subq_0.account_id__ds_partitioned__extract_month - , subq_0.account_id__ds_partitioned__extract_day - , subq_0.account_id__ds_partitioned__extract_dow - , subq_0.account_id__ds_partitioned__extract_doy - , subq_0.account_id__ds__day - , subq_0.account_id__ds__week - , subq_0.account_id__ds__month - , subq_0.account_id__ds__quarter - , subq_0.account_id__ds__year - , subq_0.account_id__ds__extract_year - , subq_0.account_id__ds__extract_quarter - , subq_0.account_id__ds__extract_month - , subq_0.account_id__ds__extract_day - , subq_0.account_id__ds__extract_dow - , subq_0.account_id__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.account_id - , subq_0.account_month - , subq_0.account_id__account_month - , subq_0.txn_count + subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.account_id__ds_partitioned__day + , subq_4.account_id__ds_partitioned__week + , subq_4.account_id__ds_partitioned__month + , subq_4.account_id__ds_partitioned__quarter + , subq_4.account_id__ds_partitioned__year + , subq_4.account_id__ds_partitioned__extract_year + , subq_4.account_id__ds_partitioned__extract_quarter + , subq_4.account_id__ds_partitioned__extract_month + , subq_4.account_id__ds_partitioned__extract_day + , subq_4.account_id__ds_partitioned__extract_dow + , subq_4.account_id__ds_partitioned__extract_doy + , subq_4.account_id__ds__day + , subq_4.account_id__ds__week + , subq_4.account_id__ds__month + , subq_4.account_id__ds__quarter + , subq_4.account_id__ds__year + , subq_4.account_id__ds__extract_year + , subq_4.account_id__ds__extract_quarter + , subq_4.account_id__ds__extract_month + , subq_4.account_id__ds__extract_day + , subq_4.account_id__ds__extract_dow + , subq_4.account_id__ds__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.account_id + , subq_4.account_month + , subq_4.account_id__account_month + , subq_4.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -140,118 +140,118 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 + ) subq_4 + ) subq_5 + ) subq_6 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_6.ds_partitioned__day - , subq_6.account_id - , subq_6.customer_id__customer_name + subq_10.ds_partitioned__day + , subq_10.account_id + , subq_10.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_3.ds_partitioned__day AS ds_partitioned__day - , subq_3.ds_partitioned__week AS ds_partitioned__week - , subq_3.ds_partitioned__month AS ds_partitioned__month - , subq_3.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_3.ds_partitioned__year AS ds_partitioned__year - , subq_3.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_3.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_3.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_3.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_3.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_3.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_3.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_3.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_3.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_3.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_3.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_3.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_3.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_5.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_5.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_5.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_5.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_5.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_5.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_3.account_id AS account_id - , subq_3.customer_id AS customer_id - , subq_3.account_id__customer_id AS account_id__customer_id - , subq_3.bridge_account__account_id AS bridge_account__account_id - , subq_3.bridge_account__customer_id AS bridge_account__customer_id - , subq_3.extra_dim AS extra_dim - , subq_3.account_id__extra_dim AS account_id__extra_dim - , subq_3.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_5.customer_name AS customer_id__customer_name - , subq_5.customer_atomic_weight AS customer_id__customer_atomic_weight + subq_7.ds_partitioned__day AS ds_partitioned__day + , subq_7.ds_partitioned__week AS ds_partitioned__week + , subq_7.ds_partitioned__month AS ds_partitioned__month + , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_7.ds_partitioned__year AS ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_9.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_9.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_9.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_9.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_9.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_9.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_7.account_id AS account_id + , subq_7.customer_id AS customer_id + , subq_7.account_id__customer_id AS account_id__customer_id + , subq_7.bridge_account__account_id AS bridge_account__account_id + , subq_7.bridge_account__customer_id AS bridge_account__customer_id + , subq_7.extra_dim AS extra_dim + , subq_7.account_id__extra_dim AS account_id__extra_dim + , subq_7.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_9.customer_name AS customer_id__customer_name + , subq_9.customer_atomic_weight AS customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT - bridge_table_src_22001.extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS account_id__extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , bridge_table_src_22001.extra_dim AS bridge_account__extra_dim - , DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__day - , DATE_TRUNC('week', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__week - , DATE_TRUNC('month', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__month - , DATE_TRUNC('quarter', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__quarter - , DATE_TRUNC('year', bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__year - , EXTRACT(year FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_year - , EXTRACT(quarter FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter - , EXTRACT(month FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_month - , EXTRACT(day FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow - , EXTRACT(doy FROM bridge_table_src_22001.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy - , bridge_table_src_22001.account_id - , bridge_table_src_22001.customer_id - , bridge_table_src_22001.customer_id AS account_id__customer_id - , bridge_table_src_22001.account_id AS bridge_account__account_id - , bridge_table_src_22001.customer_id AS bridge_account__customer_id - FROM ***************************.bridge_table bridge_table_src_22001 - ) subq_3 + bridge_table_src_22000.extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS account_id__extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , bridge_table_src_22000.extra_dim AS bridge_account__extra_dim + , DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__day + , DATE_TRUNC('week', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__week + , DATE_TRUNC('month', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__month + , DATE_TRUNC('quarter', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__quarter + , DATE_TRUNC('year', bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__year + , EXTRACT(year FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_year + , EXTRACT(quarter FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_quarter + , EXTRACT(month FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_month + , EXTRACT(day FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_dow + , EXTRACT(doy FROM bridge_table_src_22000.ds_partitioned) AS bridge_account__ds_partitioned__extract_doy + , bridge_table_src_22000.account_id + , bridge_table_src_22000.customer_id + , bridge_table_src_22000.customer_id AS account_id__customer_id + , bridge_table_src_22000.account_id AS bridge_account__account_id + , bridge_table_src_22000.customer_id AS bridge_account__customer_id + FROM ***************************.bridge_table bridge_table_src_22000 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -283,82 +283,82 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.customer_id__ds_partitioned__day - , subq_4.customer_id__ds_partitioned__week - , subq_4.customer_id__ds_partitioned__month - , subq_4.customer_id__ds_partitioned__quarter - , subq_4.customer_id__ds_partitioned__year - , subq_4.customer_id__ds_partitioned__extract_year - , subq_4.customer_id__ds_partitioned__extract_quarter - , subq_4.customer_id__ds_partitioned__extract_month - , subq_4.customer_id__ds_partitioned__extract_day - , subq_4.customer_id__ds_partitioned__extract_dow - , subq_4.customer_id__ds_partitioned__extract_doy - , subq_4.customer_id - , subq_4.customer_name - , subq_4.customer_atomic_weight - , subq_4.customer_id__customer_name - , subq_4.customer_id__customer_atomic_weight + subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.customer_id__ds_partitioned__day + , subq_8.customer_id__ds_partitioned__week + , subq_8.customer_id__ds_partitioned__month + , subq_8.customer_id__ds_partitioned__quarter + , subq_8.customer_id__ds_partitioned__year + , subq_8.customer_id__ds_partitioned__extract_year + , subq_8.customer_id__ds_partitioned__extract_quarter + , subq_8.customer_id__ds_partitioned__extract_month + , subq_8.customer_id__ds_partitioned__extract_day + , subq_8.customer_id__ds_partitioned__extract_dow + , subq_8.customer_id__ds_partitioned__extract_doy + , subq_8.customer_id + , subq_8.customer_name + , subq_8.customer_atomic_weight + , subq_8.customer_id__customer_name + , subq_8.customer_id__customer_atomic_weight FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT - customer_table_src_22003.customer_name - , customer_table_src_22003.customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_22003.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_22003.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_22003.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_22003.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_22003.ds_partitioned) AS ds_partitioned__extract_doy - , customer_table_src_22003.customer_name AS customer_id__customer_name - , customer_table_src_22003.customer_atomic_weight AS customer_id__customer_atomic_weight - , DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__day - , DATE_TRUNC('week', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__week - , DATE_TRUNC('month', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__month - , DATE_TRUNC('quarter', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__quarter - , DATE_TRUNC('year', customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__year - , EXTRACT(year FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_month - , EXTRACT(day FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM customer_table_src_22003.ds_partitioned) AS customer_id__ds_partitioned__extract_doy - , customer_table_src_22003.customer_id - FROM ***************************.customer_table customer_table_src_22003 - ) subq_4 - ) subq_5 + customer_table_src_22000.customer_name + , customer_table_src_22000.customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , customer_table_src_22000.customer_name AS customer_id__customer_name + , customer_table_src_22000.customer_atomic_weight AS customer_id__customer_atomic_weight + , DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__day + , DATE_TRUNC('week', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__week + , DATE_TRUNC('month', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__month + , DATE_TRUNC('quarter', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__quarter + , DATE_TRUNC('year', customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__year + , EXTRACT(year FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_month + , EXTRACT(day FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy + , customer_table_src_22000.customer_id + FROM ***************************.customer_table customer_table_src_22000 + ) subq_8 + ) subq_9 ON ( - subq_3.customer_id = subq_5.customer_id + subq_7.customer_id = subq_9.customer_id ) AND ( - subq_3.ds_partitioned__day = subq_5.ds_partitioned__day + subq_7.ds_partitioned__day = subq_9.ds_partitioned__day ) - ) subq_6 - ) subq_7 + ) subq_10 + ) subq_11 ON ( - subq_2.account_id = subq_7.account_id + subq_6.account_id = subq_11.account_id ) AND ( - subq_2.ds_partitioned__day = subq_7.ds_partitioned__day + subq_6.ds_partitioned__day = subq_11.ds_partitioned__day ) - ) subq_8 - ) subq_9 + ) subq_12 + ) subq_13 GROUP BY - subq_9.account_id__customer_id__customer_name -) subq_10 + subq_13.account_id__customer_id__customer_name +) subq_14 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0_optimized.sql index 7802d2f867..13473156ca 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0_optimized.sql @@ -3,31 +3,31 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_18.customer_id__customer_name AS account_id__customer_id__customer_name + subq_22.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) AS ds_partitioned__day - , bridge_table_src_22001.account_id AS account_id - , customer_table_src_22003.customer_name AS customer_id__customer_name - FROM ***************************.bridge_table bridge_table_src_22001 + DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) AS ds_partitioned__day + , bridge_table_src_22000.account_id AS account_id + , customer_table_src_22000.customer_name AS customer_id__customer_name + FROM ***************************.bridge_table bridge_table_src_22000 LEFT OUTER JOIN - ***************************.customer_table customer_table_src_22003 + ***************************.customer_table customer_table_src_22000 ON ( - bridge_table_src_22001.customer_id = customer_table_src_22003.customer_id + bridge_table_src_22000.customer_id = customer_table_src_22000.customer_id ) AND ( - DATE_TRUNC('day', bridge_table_src_22001.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22003.ds_partitioned) + DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_18 +) subq_22 ON ( - account_month_txns_src_22000.account_id = subq_18.account_id + account_month_txns_src_22000.account_id = subq_22.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day ) GROUP BY - subq_18.customer_id__customer_name + subq_22.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0.sql index 2bdfb4e837..b738d76e5d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0.sql @@ -1,536 +1,536 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_5.bookings) AS bookings - , MAX(subq_11.listings) AS listings + MAX(subq_18.bookings) AS bookings + , MAX(subq_24.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_4.bookings + subq_17.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_3.bookings) AS bookings + SUM(subq_16.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_2.bookings + subq_15.bookings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_1.ds__day - , subq_1.ds__week - , subq_1.ds__month - , subq_1.ds__quarter - , subq_1.ds__year - , subq_1.ds__extract_year - , subq_1.ds__extract_quarter - , subq_1.ds__extract_month - , subq_1.ds__extract_day - , subq_1.ds__extract_dow - , subq_1.ds__extract_doy - , subq_1.ds_partitioned__day - , subq_1.ds_partitioned__week - , subq_1.ds_partitioned__month - , subq_1.ds_partitioned__quarter - , subq_1.ds_partitioned__year - , subq_1.ds_partitioned__extract_year - , subq_1.ds_partitioned__extract_quarter - , subq_1.ds_partitioned__extract_month - , subq_1.ds_partitioned__extract_day - , subq_1.ds_partitioned__extract_dow - , subq_1.ds_partitioned__extract_doy - , subq_1.paid_at__day - , subq_1.paid_at__week - , subq_1.paid_at__month - , subq_1.paid_at__quarter - , subq_1.paid_at__year - , subq_1.paid_at__extract_year - , subq_1.paid_at__extract_quarter - , subq_1.paid_at__extract_month - , subq_1.paid_at__extract_day - , subq_1.paid_at__extract_dow - , subq_1.paid_at__extract_doy - , subq_1.booking__ds__day - , subq_1.booking__ds__week - , subq_1.booking__ds__month - , subq_1.booking__ds__quarter - , subq_1.booking__ds__year - , subq_1.booking__ds__extract_year - , subq_1.booking__ds__extract_quarter - , subq_1.booking__ds__extract_month - , subq_1.booking__ds__extract_day - , subq_1.booking__ds__extract_dow - , subq_1.booking__ds__extract_doy - , subq_1.booking__ds_partitioned__day - , subq_1.booking__ds_partitioned__week - , subq_1.booking__ds_partitioned__month - , subq_1.booking__ds_partitioned__quarter - , subq_1.booking__ds_partitioned__year - , subq_1.booking__ds_partitioned__extract_year - , subq_1.booking__ds_partitioned__extract_quarter - , subq_1.booking__ds_partitioned__extract_month - , subq_1.booking__ds_partitioned__extract_day - , subq_1.booking__ds_partitioned__extract_dow - , subq_1.booking__ds_partitioned__extract_doy - , subq_1.booking__paid_at__day - , subq_1.booking__paid_at__week - , subq_1.booking__paid_at__month - , subq_1.booking__paid_at__quarter - , subq_1.booking__paid_at__year - , subq_1.booking__paid_at__extract_year - , subq_1.booking__paid_at__extract_quarter - , subq_1.booking__paid_at__extract_month - , subq_1.booking__paid_at__extract_day - , subq_1.booking__paid_at__extract_dow - , subq_1.booking__paid_at__extract_doy - , subq_1.metric_time__day - , subq_1.metric_time__week - , subq_1.metric_time__month - , subq_1.metric_time__quarter - , subq_1.metric_time__year - , subq_1.metric_time__extract_year - , subq_1.metric_time__extract_quarter - , subq_1.metric_time__extract_month - , subq_1.metric_time__extract_day - , subq_1.metric_time__extract_dow - , subq_1.metric_time__extract_doy - , subq_1.listing - , subq_1.guest - , subq_1.host - , subq_1.booking__listing - , subq_1.booking__guest - , subq_1.booking__host - , subq_1.is_instant - , subq_1.booking__is_instant - , subq_1.bookings - , subq_1.instant_bookings - , subq_1.booking_value - , subq_1.max_booking_value - , subq_1.min_booking_value - , subq_1.bookers - , subq_1.average_booking_value - , subq_1.referred_bookings - , subq_1.median_booking_value - , subq_1.booking_value_p99 - , subq_1.discrete_booking_value_p99 - , subq_1.approximate_continuous_booking_value_p99 - , subq_1.approximate_discrete_booking_value_p99 + subq_14.ds__day + , subq_14.ds__week + , subq_14.ds__month + , subq_14.ds__quarter + , subq_14.ds__year + , subq_14.ds__extract_year + , subq_14.ds__extract_quarter + , subq_14.ds__extract_month + , subq_14.ds__extract_day + , subq_14.ds__extract_dow + , subq_14.ds__extract_doy + , subq_14.ds_partitioned__day + , subq_14.ds_partitioned__week + , subq_14.ds_partitioned__month + , subq_14.ds_partitioned__quarter + , subq_14.ds_partitioned__year + , subq_14.ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy + , subq_14.paid_at__day + , subq_14.paid_at__week + , subq_14.paid_at__month + , subq_14.paid_at__quarter + , subq_14.paid_at__year + , subq_14.paid_at__extract_year + , subq_14.paid_at__extract_quarter + , subq_14.paid_at__extract_month + , subq_14.paid_at__extract_day + , subq_14.paid_at__extract_dow + , subq_14.paid_at__extract_doy + , subq_14.booking__ds__day + , subq_14.booking__ds__week + , subq_14.booking__ds__month + , subq_14.booking__ds__quarter + , subq_14.booking__ds__year + , subq_14.booking__ds__extract_year + , subq_14.booking__ds__extract_quarter + , subq_14.booking__ds__extract_month + , subq_14.booking__ds__extract_day + , subq_14.booking__ds__extract_dow + , subq_14.booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day + , subq_14.booking__paid_at__week + , subq_14.booking__paid_at__month + , subq_14.booking__paid_at__quarter + , subq_14.booking__paid_at__year + , subq_14.booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy + , subq_14.metric_time__day + , subq_14.metric_time__week + , subq_14.metric_time__month + , subq_14.metric_time__quarter + , subq_14.metric_time__year + , subq_14.metric_time__extract_year + , subq_14.metric_time__extract_quarter + , subq_14.metric_time__extract_month + , subq_14.metric_time__extract_day + , subq_14.metric_time__extract_dow + , subq_14.metric_time__extract_doy + , subq_14.listing + , subq_14.guest + , subq_14.host + , subq_14.booking__listing + , subq_14.booking__guest + , subq_14.booking__host + , subq_14.is_instant + , subq_14.booking__is_instant + , subq_14.bookings + , subq_14.instant_bookings + , subq_14.booking_value + , subq_14.max_booking_value + , subq_14.min_booking_value + , subq_14.bookers + , subq_14.average_booking_value + , subq_14.referred_bookings + , subq_14.median_booking_value + , subq_14.booking_value_p99 + , subq_14.discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_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 + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.max_booking_value + , subq_13.min_booking_value + , subq_13.bookers + , subq_13.average_booking_value + , subq_13.referred_bookings + , subq_13.median_booking_value + , subq_13.booking_value_p99 + , subq_13.discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 + , subq_13.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' - ) subq_2 - ) subq_3 - ) subq_4 -) subq_5 + , 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_13 + ) subq_14 + WHERE subq_14.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + ) subq_15 + ) subq_16 + ) subq_17 +) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.listings + subq_23.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_9.listings) AS listings + SUM(subq_22.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_8.listings + subq_21.listings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] 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.created_at__day - , subq_7.created_at__week - , subq_7.created_at__month - , subq_7.created_at__quarter - , subq_7.created_at__year - , subq_7.created_at__extract_year - , subq_7.created_at__extract_quarter - , subq_7.created_at__extract_month - , subq_7.created_at__extract_day - , subq_7.created_at__extract_dow - , subq_7.created_at__extract_doy - , subq_7.listing__ds__day - , subq_7.listing__ds__week - , subq_7.listing__ds__month - , subq_7.listing__ds__quarter - , subq_7.listing__ds__year - , subq_7.listing__ds__extract_year - , subq_7.listing__ds__extract_quarter - , subq_7.listing__ds__extract_month - , subq_7.listing__ds__extract_day - , subq_7.listing__ds__extract_dow - , subq_7.listing__ds__extract_doy - , subq_7.listing__created_at__day - , subq_7.listing__created_at__week - , subq_7.listing__created_at__month - , subq_7.listing__created_at__quarter - , subq_7.listing__created_at__year - , subq_7.listing__created_at__extract_year - , subq_7.listing__created_at__extract_quarter - , subq_7.listing__created_at__extract_month - , subq_7.listing__created_at__extract_day - , subq_7.listing__created_at__extract_dow - , subq_7.listing__created_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.user - , subq_7.listing__user - , subq_7.country_latest - , subq_7.is_lux_latest - , subq_7.capacity_latest - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.listings - , subq_7.largest_listing - , subq_7.smallest_listing + 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.created_at__day + , subq_20.created_at__week + , subq_20.created_at__month + , subq_20.created_at__quarter + , subq_20.created_at__year + , subq_20.created_at__extract_year + , subq_20.created_at__extract_quarter + , subq_20.created_at__extract_month + , subq_20.created_at__extract_day + , subq_20.created_at__extract_dow + , subq_20.created_at__extract_doy + , subq_20.listing__ds__day + , subq_20.listing__ds__week + , subq_20.listing__ds__month + , subq_20.listing__ds__quarter + , subq_20.listing__ds__year + , subq_20.listing__ds__extract_year + , subq_20.listing__ds__extract_quarter + , subq_20.listing__ds__extract_month + , subq_20.listing__ds__extract_day + , subq_20.listing__ds__extract_dow + , subq_20.listing__ds__extract_doy + , subq_20.listing__created_at__day + , subq_20.listing__created_at__week + , subq_20.listing__created_at__month + , subq_20.listing__created_at__quarter + , subq_20.listing__created_at__year + , subq_20.listing__created_at__extract_year + , subq_20.listing__created_at__extract_quarter + , subq_20.listing__created_at__extract_month + , subq_20.listing__created_at__extract_day + , subq_20.listing__created_at__extract_dow + , subq_20.listing__created_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.user + , subq_20.listing__user + , subq_20.country_latest + , subq_20.is_lux_latest + , subq_20.capacity_latest + , subq_20.listing__country_latest + , subq_20.listing__is_lux_latest + , subq_20.listing__capacity_latest + , subq_20.listings + , subq_20.largest_listing + , subq_20.smallest_listing FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_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.created_at__day + , subq_19.created_at__week + , subq_19.created_at__month + , subq_19.created_at__quarter + , subq_19.created_at__year + , subq_19.created_at__extract_year + , subq_19.created_at__extract_quarter + , subq_19.created_at__extract_month + , subq_19.created_at__extract_day + , subq_19.created_at__extract_dow + , subq_19.created_at__extract_doy + , subq_19.listing__ds__day + , subq_19.listing__ds__week + , subq_19.listing__ds__month + , subq_19.listing__ds__quarter + , subq_19.listing__ds__year + , subq_19.listing__ds__extract_year + , subq_19.listing__ds__extract_quarter + , subq_19.listing__ds__extract_month + , subq_19.listing__ds__extract_day + , subq_19.listing__ds__extract_dow + , subq_19.listing__ds__extract_doy + , subq_19.listing__created_at__day + , subq_19.listing__created_at__week + , subq_19.listing__created_at__month + , subq_19.listing__created_at__quarter + , subq_19.listing__created_at__year + , subq_19.listing__created_at__extract_year + , subq_19.listing__created_at__extract_quarter + , subq_19.listing__created_at__extract_month + , subq_19.listing__created_at__extract_day + , subq_19.listing__created_at__extract_dow + , subq_19.listing__created_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.user + , subq_19.listing__user + , subq_19.country_latest + , subq_19.is_lux_latest + , subq_19.capacity_latest + , subq_19.listing__country_latest + , subq_19.listing__is_lux_latest + , subq_19.listing__capacity_latest + , subq_19.listings + , subq_19.largest_listing + , subq_19.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT 1 AS listings - , listings_latest_src_28005.capacity AS largest_listing - , listings_latest_src_28005.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS created_at__extract_doy - , listings_latest_src_28005.country AS country_latest - , listings_latest_src_28005.is_lux AS is_lux_latest - , listings_latest_src_28005.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28005.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28005.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28005.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28005.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28005.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28005.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28005.country AS listing__country_latest - , listings_latest_src_28005.is_lux AS listing__is_lux_latest - , listings_latest_src_28005.capacity AS listing__capacity_latest - , listings_latest_src_28005.listing_id AS listing - , listings_latest_src_28005.user_id AS user - , listings_latest_src_28005.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28005 - ) subq_6 - ) subq_7 - WHERE subq_7.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' - ) subq_8 - ) subq_9 - ) subq_10 -) subq_11 + , 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_19 + ) subq_20 + WHERE subq_20.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + ) subq_21 + ) subq_22 + ) subq_23 +) subq_24 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 43332be222..f5311ea7c8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_17.bookings) AS bookings - , MAX(subq_23.listings) AS listings + MAX(subq_30.bookings) AS bookings + , MAX(subq_36.listings) AS listings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -11,9 +11,9 @@ FROM ( -- Compute Metrics via Expressions SELECT SUM(1) AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 + FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' -) subq_17 +) subq_30 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -23,6 +23,6 @@ CROSS JOIN ( -- Compute Metrics via Expressions SELECT SUM(1) AS listings - FROM ***************************.dim_listings_latest listings_latest_src_28005 + FROM ***************************.dim_listings_latest listings_latest_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' -) subq_23 +) subq_36 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0.sql index 1cd73f8aa2..9bc8e39468 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0.sql @@ -1,241 +1,241 @@ -- Compute Metrics via Expressions SELECT - subq_7.user__home_state - , subq_7.identity_verifications + subq_16.user__home_state + , subq_16.identity_verifications FROM ( -- Aggregate Measures SELECT - subq_6.user__home_state - , SUM(subq_6.identity_verifications) AS identity_verifications + subq_15.user__home_state + , SUM(subq_15.identity_verifications) AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'user__home_state'] SELECT - subq_5.user__home_state - , subq_5.identity_verifications + subq_14.user__home_state + , subq_14.identity_verifications FROM ( -- Join Standard Outputs SELECT - subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__day AS user__ds_partitioned__day - , subq_2.user AS user - , subq_4.home_state AS user__home_state - , subq_2.identity_verifications AS identity_verifications + subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_13.ds_partitioned__day AS user__ds_partitioned__day + , subq_11.user AS user + , subq_13.home_state AS user__home_state + , subq_11.identity_verifications AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT - subq_1.ds_partitioned__day - , subq_1.user - , subq_1.identity_verifications + subq_10.ds_partitioned__day + , subq_10.user + , subq_10.identity_verifications 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.verification__ds__day - , subq_0.verification__ds__week - , subq_0.verification__ds__month - , subq_0.verification__ds__quarter - , subq_0.verification__ds__year - , subq_0.verification__ds__extract_year - , subq_0.verification__ds__extract_quarter - , subq_0.verification__ds__extract_month - , subq_0.verification__ds__extract_day - , subq_0.verification__ds__extract_dow - , subq_0.verification__ds__extract_doy - , subq_0.verification__ds_partitioned__day - , subq_0.verification__ds_partitioned__week - , subq_0.verification__ds_partitioned__month - , subq_0.verification__ds_partitioned__quarter - , subq_0.verification__ds_partitioned__year - , subq_0.verification__ds_partitioned__extract_year - , subq_0.verification__ds_partitioned__extract_quarter - , subq_0.verification__ds_partitioned__extract_month - , subq_0.verification__ds_partitioned__extract_day - , subq_0.verification__ds_partitioned__extract_dow - , subq_0.verification__ds_partitioned__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.verification - , subq_0.user - , subq_0.verification__user - , subq_0.verification_type - , subq_0.verification__verification_type - , subq_0.identity_verifications + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.verification__ds__day + , subq_9.verification__ds__week + , subq_9.verification__ds__month + , subq_9.verification__ds__quarter + , subq_9.verification__ds__year + , subq_9.verification__ds__extract_year + , subq_9.verification__ds__extract_quarter + , subq_9.verification__ds__extract_month + , subq_9.verification__ds__extract_day + , subq_9.verification__ds__extract_dow + , subq_9.verification__ds__extract_doy + , subq_9.verification__ds_partitioned__day + , subq_9.verification__ds_partitioned__week + , subq_9.verification__ds_partitioned__month + , subq_9.verification__ds_partitioned__quarter + , subq_9.verification__ds_partitioned__year + , subq_9.verification__ds_partitioned__extract_year + , subq_9.verification__ds_partitioned__extract_quarter + , subq_9.verification__ds_partitioned__extract_month + , subq_9.verification__ds_partitioned__extract_day + , subq_9.verification__ds_partitioned__extract_dow + , subq_9.verification__ds_partitioned__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.verification + , subq_9.user + , subq_9.verification__user + , subq_9.verification_type + , subq_9.verification__verification_type + , subq_9.identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28004.ds) AS ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type - , DATE_TRUNC('day', id_verifications_src_28004.ds) AS verification__ds__day - , DATE_TRUNC('week', id_verifications_src_28004.ds) AS verification__ds__week - , DATE_TRUNC('month', id_verifications_src_28004.ds) AS verification__ds__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds) AS verification__ds__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds) AS verification__ds__year - , EXTRACT(year FROM id_verifications_src_28004.ds) AS verification__ds__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds) AS verification__ds__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds) AS verification__ds__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds) AS verification__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28004.ds) AS verification__ds__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds) AS verification__ds__extract_doy - , DATE_TRUNC('day', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__day - , DATE_TRUNC('week', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__week - , DATE_TRUNC('month', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__month - , DATE_TRUNC('quarter', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__quarter - , DATE_TRUNC('year', id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__year - , EXTRACT(year FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_year - , EXTRACT(quarter FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_quarter - , EXTRACT(month FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_month - , EXTRACT(day FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_dow - , EXTRACT(doy FROM id_verifications_src_28004.ds_partitioned) AS verification__ds_partitioned__extract_doy - , id_verifications_src_28004.verification_type AS verification__verification_type - , id_verifications_src_28004.verification_id AS verification - , id_verifications_src_28004.user_id AS user - , id_verifications_src_28004.user_id AS verification__user - FROM ***************************.fct_id_verifications id_verifications_src_28004 - ) subq_0 - ) subq_1 - ) subq_2 + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type + , DATE_TRUNC('day', id_verifications_src_28000.ds) AS verification__ds__day + , DATE_TRUNC('week', id_verifications_src_28000.ds) AS verification__ds__week + , DATE_TRUNC('month', id_verifications_src_28000.ds) AS verification__ds__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds) AS verification__ds__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds) AS verification__ds__year + , EXTRACT(year FROM id_verifications_src_28000.ds) AS verification__ds__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds) AS verification__ds__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds) AS verification__ds__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds) AS verification__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28000.ds) AS verification__ds__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds) AS verification__ds__extract_doy + , DATE_TRUNC('day', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__day + , DATE_TRUNC('week', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__week + , DATE_TRUNC('month', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__month + , DATE_TRUNC('quarter', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__quarter + , DATE_TRUNC('year', id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__year + , EXTRACT(year FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_year + , EXTRACT(quarter FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_quarter + , EXTRACT(month FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_month + , EXTRACT(day FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_dow + , EXTRACT(doy FROM id_verifications_src_28000.ds_partitioned) AS verification__ds_partitioned__extract_doy + , id_verifications_src_28000.verification_type AS verification__verification_type + , id_verifications_src_28000.verification_id AS verification + , id_verifications_src_28000.user_id AS user + , id_verifications_src_28000.user_id AS verification__user + FROM ***************************.fct_id_verifications id_verifications_src_28000 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state', 'ds_partitioned__day', 'user'] SELECT - subq_3.ds_partitioned__day - , subq_3.user - , subq_3.home_state + subq_12.ds_partitioned__day + , subq_12.user + , subq_12.home_state FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - DATE_TRUNC('day', users_ds_source_src_28008.ds) AS ds__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds) AS ds__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds) AS ds__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds) AS ds__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds) AS ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28008.ds) AS ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds) AS ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.created_at) AS created_at__day - , DATE_TRUNC('week', users_ds_source_src_28008.created_at) AS created_at__week - , DATE_TRUNC('month', users_ds_source_src_28008.created_at) AS created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.created_at) AS created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.created_at) AS created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28008.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.created_at) AS created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds_partitioned) AS ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state - , DATE_TRUNC('day', users_ds_source_src_28008.ds) AS user__ds__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds) AS user__ds__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds) AS user__ds__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds) AS user__ds__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds) AS user__ds__year - , EXTRACT(year FROM users_ds_source_src_28008.ds) AS user__ds__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds) AS user__ds__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds) AS user__ds__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds) AS user__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28008.ds) AS user__ds__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds) AS user__ds__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.created_at) AS user__created_at__day - , DATE_TRUNC('week', users_ds_source_src_28008.created_at) AS user__created_at__week - , DATE_TRUNC('month', users_ds_source_src_28008.created_at) AS user__created_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.created_at) AS user__created_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.created_at) AS user__created_at__year - , EXTRACT(year FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.created_at) AS user__created_at__extract_doy - , DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__day - , DATE_TRUNC('week', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__week - , DATE_TRUNC('month', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__month - , DATE_TRUNC('quarter', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__quarter - , DATE_TRUNC('year', users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__year - , EXTRACT(year FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_month - , EXTRACT(day FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28008.ds_partitioned) AS user__ds_partitioned__extract_doy - , users_ds_source_src_28008.home_state AS user__home_state - , users_ds_source_src_28008.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28008 - ) subq_3 - ) subq_4 + DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_12 + ) subq_13 ON ( - subq_2.user = subq_4.user + subq_11.user = subq_13.user ) AND ( - subq_2.ds_partitioned__day = subq_4.ds_partitioned__day + subq_11.ds_partitioned__day = subq_13.ds_partitioned__day ) - ) subq_5 - ) subq_6 + ) subq_14 + ) subq_15 GROUP BY - subq_6.user__home_state -) subq_7 + subq_15.user__home_state +) subq_16 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0_optimized.sql index 9f15f9bb3d..54ea641813 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0_optimized.sql @@ -3,8 +3,8 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - users_ds_source_src_28008.home_state AS user__home_state - , SUM(subq_10.identity_verifications) AS identity_verifications + users_ds_source_src_28000.home_state AS user__home_state + , SUM(subq_19.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' -- Metric Time Dimension 'ds' @@ -13,15 +13,15 @@ FROM ( DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications - FROM ***************************.fct_id_verifications id_verifications_src_28004 -) subq_10 + FROM ***************************.fct_id_verifications id_verifications_src_28000 +) subq_19 LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_28008 + ***************************.dim_users users_ds_source_src_28000 ON ( - subq_10.user = users_ds_source_src_28008.user_id + subq_19.user = users_ds_source_src_28000.user_id ) AND ( - subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28008.ds_partitioned) + subq_19.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) ) GROUP BY - users_ds_source_src_28008.home_state + users_ds_source_src_28000.home_state diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/BigQuery/test_render_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/BigQuery/test_render_query__query0.sql index 1d745a8a83..d35cb4ec49 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/BigQuery/test_render_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/BigQuery/test_render_query__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 -) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 +) subq_11 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/BigQuery/test_render_write_to_table_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/BigQuery/test_render_write_to_table_query__query0.sql index 7b3ea745e5..6c32ca1190 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/BigQuery/test_render_write_to_table_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/BigQuery/test_render_write_to_table_query__query0.sql @@ -11,8 +11,8 @@ CREATE TABLE ***************************.test_table AS ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 - ) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 + ) subq_11 GROUP BY metric_time__day ) diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/Databricks/test_render_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/Databricks/test_render_query__query0.sql index 767b48356d..bf5376debe 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/Databricks/test_render_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/Databricks/test_render_query__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 -) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 +) subq_11 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/Databricks/test_render_write_to_table_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/Databricks/test_render_write_to_table_query__query0.sql index 6f073ef8cf..77758601b8 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/Databricks/test_render_write_to_table_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/Databricks/test_render_write_to_table_query__query0.sql @@ -11,8 +11,8 @@ CREATE TABLE ***************************.test_table AS ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 - ) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 + ) subq_11 GROUP BY metric_time__day ) diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/DuckDB/test_render_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/DuckDB/test_render_query__query0.sql index 767b48356d..bf5376debe 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/DuckDB/test_render_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/DuckDB/test_render_query__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 -) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 +) subq_11 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/DuckDB/test_render_write_to_table_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/DuckDB/test_render_write_to_table_query__query0.sql index 6f073ef8cf..77758601b8 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/DuckDB/test_render_write_to_table_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/DuckDB/test_render_write_to_table_query__query0.sql @@ -11,8 +11,8 @@ CREATE TABLE ***************************.test_table AS ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 - ) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 + ) subq_11 GROUP BY metric_time__day ) diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/Postgres/test_render_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/Postgres/test_render_query__query0.sql index 767b48356d..bf5376debe 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/Postgres/test_render_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/Postgres/test_render_query__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 -) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 +) subq_11 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/Postgres/test_render_write_to_table_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/Postgres/test_render_write_to_table_query__query0.sql index 6f073ef8cf..77758601b8 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/Postgres/test_render_write_to_table_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/Postgres/test_render_write_to_table_query__query0.sql @@ -11,8 +11,8 @@ CREATE TABLE ***************************.test_table AS ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 - ) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 + ) subq_11 GROUP BY metric_time__day ) diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/Redshift/test_render_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/Redshift/test_render_query__query0.sql index 767b48356d..bf5376debe 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/Redshift/test_render_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/Redshift/test_render_query__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 -) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 +) subq_11 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/Redshift/test_render_write_to_table_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/Redshift/test_render_write_to_table_query__query0.sql index 6f073ef8cf..77758601b8 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/Redshift/test_render_write_to_table_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/Redshift/test_render_write_to_table_query__query0.sql @@ -11,8 +11,8 @@ CREATE TABLE ***************************.test_table AS ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 - ) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 + ) subq_11 GROUP BY metric_time__day ) diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/Snowflake/test_render_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/Snowflake/test_render_query__query0.sql index 767b48356d..bf5376debe 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/Snowflake/test_render_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/Snowflake/test_render_query__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 -) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 +) subq_11 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/Snowflake/test_render_write_to_table_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/Snowflake/test_render_write_to_table_query__query0.sql index 6f073ef8cf..77758601b8 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/Snowflake/test_render_write_to_table_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/Snowflake/test_render_write_to_table_query__query0.sql @@ -11,8 +11,8 @@ CREATE TABLE ***************************.test_table AS ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 - ) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 + ) subq_11 GROUP BY metric_time__day ) diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/Trino/test_render_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/Trino/test_render_query__query0.sql index 767b48356d..bf5376debe 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/Trino/test_render_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/Trino/test_render_query__query0.sql @@ -10,7 +10,7 @@ FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 -) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 +) subq_11 GROUP BY metric_time__day diff --git a/metricflow/test/snapshots/test_rendered_query.py/str/Trino/test_render_write_to_table_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/str/Trino/test_render_write_to_table_query__query0.sql index 6f073ef8cf..77758601b8 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/str/Trino/test_render_write_to_table_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/str/Trino/test_render_write_to_table_query__query0.sql @@ -11,8 +11,8 @@ CREATE TABLE ***************************.test_table AS ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_1 - ) subq_2 + FROM ***************************.fct_bookings bookings_source_src_10000 + ) subq_11 GROUP BY metric_time__day ) diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0.sql index 8cb7b567a7..7de2c6adc0 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_join_to_time_spine + subq_15.metric_time__day + , subq_15.bookings AS bookings_join_to_time_spine FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28001.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28001.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28001.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28001.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28001.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28001.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28001.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28001.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28001.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28001.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28001.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28001.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY metric_time__day - ) subq_3 + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0_optimized.sql index 65f70748f5..d2c0f963d3 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings_join_to_time_spine -FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings_join_to_time_spine +FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -16,10 +16,10 @@ LEFT OUTER JOIN ( SELECT DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day -) subq_10 +) subq_19 ON - subq_12.ds = subq_10.metric_time__day + subq_21.ds = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0.sql index 4f54d41a0e..289a5989ee 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_join_to_time_spine + subq_15.metric_time__day + , subq_15.bookings AS bookings_join_to_time_spine FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0_optimized.sql index 0a37042296..f39f546970 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings_join_to_time_spine -FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings_join_to_time_spine +FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -16,10 +16,10 @@ LEFT OUTER JOIN ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day -) subq_10 +) subq_19 ON - subq_12.ds = subq_10.metric_time__day + subq_21.ds = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/DuckDB/test_simple_join_to_time_spine__plan0.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/DuckDB/test_simple_join_to_time_spine__plan0.sql index 314870a5d1..b034f86fdd 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/DuckDB/test_simple_join_to_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/DuckDB/test_simple_join_to_time_spine__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_join_to_time_spine + subq_15.metric_time__day + , subq_15.bookings AS bookings_join_to_time_spine FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/DuckDB/test_simple_join_to_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/DuckDB/test_simple_join_to_time_spine__plan0_optimized.sql index 0a37042296..f39f546970 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/DuckDB/test_simple_join_to_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/DuckDB/test_simple_join_to_time_spine__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings_join_to_time_spine -FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings_join_to_time_spine +FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -16,10 +16,10 @@ LEFT OUTER JOIN ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day -) subq_10 +) subq_19 ON - subq_12.ds = subq_10.metric_time__day + subq_21.ds = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0.sql index 314870a5d1..b034f86fdd 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_join_to_time_spine + subq_15.metric_time__day + , subq_15.bookings AS bookings_join_to_time_spine FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0_optimized.sql index 0a37042296..f39f546970 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings_join_to_time_spine -FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings_join_to_time_spine +FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -16,10 +16,10 @@ LEFT OUTER JOIN ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day -) subq_10 +) subq_19 ON - subq_12.ds = subq_10.metric_time__day + subq_21.ds = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0.sql index 7a5db10dcb..10aa64e8e4 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_join_to_time_spine + subq_15.metric_time__day + , subq_15.bookings AS bookings_join_to_time_spine FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28001.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28001.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0_optimized.sql index 0a37042296..f39f546970 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings_join_to_time_spine -FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings_join_to_time_spine +FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -16,10 +16,10 @@ LEFT OUTER JOIN ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day -) subq_10 +) subq_19 ON - subq_12.ds = subq_10.metric_time__day + subq_21.ds = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0.sql index a43e8a7ec5..e494d9625d 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_join_to_time_spine + subq_15.metric_time__day + , subq_15.bookings AS bookings_join_to_time_spine FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0_optimized.sql index 0a37042296..f39f546970 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings_join_to_time_spine -FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings_join_to_time_spine +FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -16,10 +16,10 @@ LEFT OUTER JOIN ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day -) subq_10 +) subq_19 ON - subq_12.ds = subq_10.metric_time__day + subq_21.ds = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0.sql index dddc2cb798..114cf3cc6a 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0.sql @@ -1,227 +1,227 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.bookings AS bookings_join_to_time_spine + subq_15.metric_time__day + , subq_15.bookings AS bookings_join_to_time_spine FROM ( -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_3.bookings AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_12.bookings AS bookings FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_5 - ) subq_4 + subq_14.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_2.metric_time__day - , SUM(subq_2.bookings) AS bookings + subq_11.metric_time__day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_1.metric_time__day - , subq_1.bookings + subq_10.metric_time__day + , subq_10.bookings 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 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28001.booking_value - , bookings_source_src_28001.booking_value AS max_booking_value - , bookings_source_src_28001.booking_value AS min_booking_value - , bookings_source_src_28001.guest_id AS bookers - , bookings_source_src_28001.booking_value AS average_booking_value - , bookings_source_src_28001.booking_value AS booking_payments + , 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_28001.booking_value AS median_booking_value - , bookings_source_src_28001.booking_value AS booking_value_p99 - , bookings_source_src_28001.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28001.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28001.is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS paid_at__extract_doy - , bookings_source_src_28001.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28001.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28001.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28001.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28001.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28001.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28001.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28001.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28001.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28001.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28001.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28001.listing_id AS listing - , bookings_source_src_28001.guest_id AS guest - , bookings_source_src_28001.host_id AS host - , bookings_source_src_28001.listing_id AS booking__listing - , bookings_source_src_28001.guest_id AS booking__guest - , bookings_source_src_28001.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_0 - ) subq_1 - ) subq_2 + , 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_9 + ) subq_10 + ) subq_11 GROUP BY - subq_2.metric_time__day - ) subq_3 + subq_11.metric_time__day + ) subq_12 ON - subq_4.metric_time__day = subq_3.metric_time__day -) subq_6 + subq_13.metric_time__day = subq_12.metric_time__day +) subq_15 diff --git a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0_optimized.sql b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0_optimized.sql index 0a37042296..f39f546970 100644 --- a/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ds AS metric_time__day - , subq_10.bookings AS bookings_join_to_time_spine -FROM ***************************.mf_time_spine subq_12 + subq_21.ds AS metric_time__day + , subq_19.bookings AS bookings_join_to_time_spine +FROM ***************************.mf_time_spine subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -16,10 +16,10 @@ LEFT OUTER JOIN ( SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28001 - ) subq_9 + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_18 GROUP BY metric_time__day -) subq_10 +) subq_19 ON - subq_12.ds = subq_10.metric_time__day + subq_21.ds = subq_19.metric_time__day